-2

重複の可能性:
ファイルから特殊記号を読み取る

ファイルを別のファイルにコピーしようとしています。ファイルはエンコーディング標準 UTF8 を使用しており、ファイルには特殊文字も含まれています。プログラムは、同じ形式の別のファイルに特殊文字をコピーすることができません。ファイルは、特殊記号のボックス形状で乱れています。

 try 
  {
   BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(new File("path of the file")),"UTF8") ;
  BufferedWriter bw= new BufferedWriter(new OutputStreamReader(new FileOutputStream(new File("path of the output file");
    while(br.readLine()!=null)
   {
     //code here to read and write from a file to another.


    }

   }
  catch(Exception ex  
 { 
 ex.printStackTrace();
  }
4

1 に答える 1

0
BufferedWriter bw = new BufferedWriter(
        new OutputStreamWriter(
            new FileOutputStream(new File("path of the output file")),
            "UTF-8"));

またはJava 7で使用しますFiles.copy

于 2012-12-14T10:52:50.857 に答える