⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 changeencoding.java

📁 北京大学出版社的
💻 JAVA
字号:
package examples.i18n; 
import java.io.*;
/** A class to convert a file from one
  * character-encoding scheme to another
  */
public class ChangeEncoding {
   /**
     * @param args Two parameters are required for
     *             identifying the input and output
     *             filenames
     */
   public static void main( String[] args ) {
      if ( args.length < 2 ) {
         System.out.println( "Please provide an input "
                            + "and output filename." );
      } else try {
         FileInputStream fileIn
            = new FileInputStream( args[0] );
         FileOutputStream fileOut
            = new FileOutputStream( args[1] );
         String encoding
            = System.getProperty( "file.encoding" );
         String cyrillic = "8859_5";
         InputStreamReader isr
            = new InputStreamReader( fileIn,
                                     encoding );
         OutputStreamWriter osr
            = new OutputStreamWriter( fileOut,
                                      cyrillic );
         BufferedReader br = new BufferedReader( isr );
         PrintWriter pw = new PrintWriter( osr );
         String nextLine = br.readLine();
         while ( nextLine != null ) {
            pw.println( nextLine );
            nextLine = br.readLine();
         }
         pw.close();
         br.close();
      } catch( Exception x ) {
         System.out.println( x );
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -