我有这么一段代码
int lineDel=1;
BufferedReader br = new BufferedReader(new InputStreamReader(
    new FileInputStream("D:/S_D_80075911_999998_20100616_20100618013538092[1].txt"), "utf-8"));
StringBuffer sb=new StringBuffer(4096);
String temp=null;
int line=0;
while((temp=br.readLine())!=null){
  line++;
  if(line==lineDel) continue;
  sb.append(temp).append( "\r\n ");
}
br.close();
BufferedWriter bw=new BufferedWriter(new FileWriter("D:/S_D_80075911_999998_20100616_20100618013538092[1].txt"));
bw.write(sb.toString());
bw.close();
这个方法就是读一个txt文件,将他的第一行去掉在存在这个文件里,现在有问题的是,如果我这个文件里面有中文,英文,日文,韩文。他通过读取文件拿到的sb.toString()打听出来有很多乱码???号。比如我txt文件里存这些APPLE US 257     Colorme(Beijing)Info Tech Co.,Ltd Game Zone   1 2 0.36 06/16/2010 06/16/2010 GBP GB GBP       335934652 0.59             APPLE US 223   Colorme(Beijing)Info Tech Co.,Ltd 是男人就下100层  免费   7 6 0 06/07/2010 06/13/2010 CAD CA CAD       322878243 0            
APPLE US 2586     Colorme(Beijing)Info Tech Co.,Ltd M.A.A. - Monsters against aliens (Lite)   1 2 0 06/16/2010 06/16/2010 GBP GB GBP       351834300 0             APPLE US 525   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   1 31 0 06/07/2010 06/13/2010 NOK NO EUR       332030082 0            
APPLE US 525     Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   1 2 0 06/16/2010 06/16/2010 EUR BE EUR       332030082 0             APPLE US 750   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner Free   1 59 0 06/07/2010 06/13/2010 NOK NO EUR       312041202 0            
APPLE US 963     Colorme(Beijing)Info Tech Co.,Ltd I'm Destroyer Lite   1 9 0 06/16/2010 06/16/2010 EUR BE EUR       324538899 0             APPLE US 750   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner Free   1 207 0 06/07/2010 06/13/2010 DKK DK EUR       312041202 0            
APPLE US 525     Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   1 2 0 06/16/2010 06/16/2010 EUR GR EUR       332030082 0             APPLE US 868   Colorme(Beijing)Info Tech Co.,Ltd A Miser Tiger 욕심쟁이 호랑이 Lite   1 1 0 06/07/2010 06/13/2010 DKK DK EUR       362283191 0            
APPLE US 750     Colorme(Beijing)Info Tech Co.,Ltd Golden Miner Free   7 1 0 06/16/2010 06/16/2010 EUR IE EUR       312041202 0             APPLE US 963   Colorme(Beijing)Info Tech Co.,Ltd I'm Destroyer Lite   1 64 0 06/07/2010 06/13/2010 CHF CH EUR       324538899 0            
APPLE US 525     Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   1 2 0 06/16/2010 06/16/2010 EUR IE EUR       332030082 0             APPLE US 750   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner Free   7 529 0 06/07/2010 06/13/2010 AUD AU AUD       312041202 0            
APPLE US 12345     Colorme(Beijing)Info Tech Co.,Ltd Hero Hoops 슛 달인 무료   1 5 0 06/16/2010 06/16/2010 EUR IT EUR       376313200 0             APPLE US 525   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   1 106 0 06/07/2010 06/13/2010 AUD AU AUD       332030082 0            
APPLE US 2586     Colorme(Beijing)Info Tech Co.,Ltd M.A.A. - Monsters against aliens (Lite)   1 1 0 06/16/2010 06/16/2010 EUR NL EUR       351834300 0             APPLE US 866   Colorme(Beijing)Info Tech Co.,Ltd A Miser Tiger Lite   1 5 0 06/07/2010 06/13/2010 AUD AU AUD       362284059 0            
APPLE US 1901     Colorme(Beijing)Info Tech Co.,Ltd iCS   1 1 0.97 06/16/2010 06/16/2010 EUR NL EUR       318693896 1.59             APPLE US 120   Colorme(Beijing)Info Tech Co.,Ltd 黄金矿工 免费   1 12 0 06/07/2010 06/13/2010 AUD AU AUD       312355980 0            
APPLE US 525     Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   1 16 0 06/16/2010 06/16/2010 EUR NL EUR       332030082 0             APPLE US 1100   Colorme(Beijing)Info Tech Co.,Ltd Flowerz   1 2 0.76 06/07/2010 06/13/2010 AUD AU AUD       315608188 1.19            
APPLE US 321     Colorme(Beijing)Info Tech Co.,Ltd 파괴자   1 1 0.97 06/16/2010 06/16/2010 EUR ES EUR       363091664 1.59             APPLE US 963   Colorme(Beijing)Info Tech Co.,Ltd I'm Destroyer Lite   1 41 0 06/07/2010 06/13/2010 AUD AU AUD       324538899 0            
APPLE US 652     Colorme(Beijing)Info Tech Co.,Ltd M.A.A. - 怪兽大战外星人 免费   1 1 0 06/16/2010 06/16/2010 EUR ES EUR       353955080 0             APPLE US 1901   Colorme(Beijing)Info Tech Co.,Ltd iCS   1 4 1.58 06/07/2010 06/13/2010 AUD AU AUD       318693896 2.49            
APPLE US 1200     Colorme(Beijing)Info Tech Co.,Ltd Super Jump Lite   1 1 0 06/16/2010 06/16/2010 EUR ES EUR       315757762 0             APPLE US 525   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner 2 Free   7 27 0 06/07/2010 06/13/2010 AUD AU AUD       332030082 0            
APPLE US 1902     Colorme(Beijing)Info Tech Co.,Ltd iCS Lite   1 1 0 06/16/2010 06/16/2010 EUR ES EUR       318697537 0             APPLE US 257   Colorme(Beijing)Info Tech Co.,Ltd Game Zone   1 8 81 06/07/2010 06/13/2010 JPY JP JPY       335934652 115            
APPLE US 12345     Colorme(Beijing)Info Tech Co.,Ltd Hero Hoops 슛 달인 무료   1 3 0 06/16/2010 06/16/2010 EUR ES EUR       376313200 0             APPLE US 750   Colorme(Beijing)Info Tech Co.,Ltd Golden Miner Free   7 42 0 06/07/2010 06/13/2010 JPY JP JPY       312041202 0            
APPLE US 2586     Colorme(Beijing)Info Tech Co.,Ltd M.A.A. - Monsters against aliens (Lite)   7 1 0 06/16/2010 06/16/2010 EUR ES EUR       351834300 0             APPLE US 868   Colorme(Beijing)Info Tech Co.,Ltd A Miser Tiger 욕심쟁이 호랑이 Lite   1 2 0 06/07/2010 06/13/2010 USD HK USD       362283191 0            
APPLE US 2586     Colorme(Beijing)Info Tech Co.,Ltd M.A.A. - Monsters against aliens (Lite)   7 1 0 06/16/2010 06/16/2010 CAD CA CAD       351834300 0             APPLE US 223   Colorme(Beijing)Info Tech Co.,Ltd 是男人就下100层  免费   1 5 0 06/07/2010 06/13/2010 USD SG USD       322878243 0            
APPLE US 1000     Colorme(Beijing)Info Tech Co.,Ltd Flowerz Lite   1 5 0 06/16/2010 06/16/2010 CAD CA CAD       313826320 0             APPLE US 120   Colorme(Beijing)Info Tech Co.,Ltd 黄金矿工 免费   1 28 0 06/07/2010 06/13/2010 USD SG USD       312355980 0            
它就会出很多乱码,这怎么解决!!谢谢谁帮我解决下

解决方案 »

  1.   


    BufferedWriter bw=new BufferedWriter(new FileWriter("D:/S_D_80075911_999998_20100616_20100618013538092[1].txt"),"utf-8");试试
      

  2.   

    就类似于这样:import java.io.*;
    public class Stream{
        public static void main(String rags[])throws Exception{
             OutputStream out=new FileOutputStream("2.txt");
             InputStream in = Stream.class.getResourceAsStream("1.txt");
             int ch=0;
             while((ch=in.read())!=-1){//一个字节一个字节的读
                 if(ch=='\n'){
                     break;
                 } 
             }
             int len=0;
             byte[] buff=new byte[1024];
             while((len=in.read(buff))!=-1){
                  out.write(buff,0,len);
             }
             out.close();
             in.close();
        }
    }
      

  3.   

    同5楼。FileInputStream in = new FileInputStream(new File("C:\\Documents and Settings\\Administrator\\桌面\\新建 文本文档.txt"));
    FileOutputStream out = new FileOutputStream(new File("C:\\Documents and Settings\\Administrator\\桌面\\新建 文本文档2.txt"));
    int ch=0;
            while((ch=in.read())!=-1){
                if(ch==10)
                    break;
            }
            byte[] buffer = new byte[1024];
    while(true)
    {
    int b = in.read(buffer);
    if(b == -1)
    break;
    else
    out.write(buffer,0,b);
    }
            out.close();
            in.close();