net.iharder.Base64.decodeFromFile()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中net.iharder.Base64.decodeFromFile()方法的一些代码示例,展示了Base64.decodeFromFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.decodeFromFile()方法的具体详情如下:
包路径:net.iharder.Base64
类名称:Base64
方法名:decodeFromFile

Base64.decodeFromFile介绍

[英]Convenience method for reading a base64-encoded file and decoding it.

As of v 2.3, if there is a error, the method will throw an java.io.IOException. This is new to v2.3! In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.
[中]读取base64编码文件并对其进行解码的简便方法。
从v2.3开始,如果出现错误,该方法将抛出一个java。木卫一。例外。这是v2的新特性。3.在早期版本中,它只是返回false,但回想起来,这是一种非常糟糕的处理方法。

代码示例

代码示例来源:origin: Nextdoor/bender

/**
 * Reads <tt>infile</tt> and decodes it to <tt>outfile</tt>.
 *
 * @param infile Input file
 * @param outfile Output file
 * @throws java.io.IOException if there is an error
 * @since 2.2
 */
public static void decodeFileToFile( String infile, String outfile )
throws java.io.IOException {
  
  byte[] decoded = Base64.decodeFromFile( infile );
  java.io.OutputStream out = null;
  try{
    out = new java.io.BufferedOutputStream(
       new java.io.FileOutputStream( outfile ) );
    out.write( decoded );
  }   // end try
  catch( java.io.IOException e ) {
    throw e; // Catch and release to execute finally{}
  }   // end catch
  finally {
    try { out.close(); }
    catch( Exception ex ){}
  }   // end finally    
}   // end decodeFileToFile

代码示例来源:origin: pelotoncycle/weberknecht

/**
 * Reads <tt>infile</tt> and decodes it to <tt>outfile</tt>.
 *
 * @param infile Input file
 * @param outfile Output file
 * @throws java.io.IOException if there is an error
 * @since 2.2
 */
public static void decodeFileToFile( String infile, String outfile )
throws java.io.IOException {
  
  byte[] decoded = Base64.decodeFromFile( infile );
  java.io.OutputStream out = null;
  try{
    out = new java.io.BufferedOutputStream(
       new java.io.FileOutputStream( outfile ) );
    out.write( decoded );
  }   // end try
  catch( java.io.IOException e ) {
    throw e; // Catch and release to execute finally{}
  }   // end catch
  finally {
    try { out.close(); }
    catch( Exception ex ){}
  }   // end finally    
}   // end decodeFileToFile

相关文章