while (inFile.readLine()!=null){
System.out.print(inFile.readLine());
}//第一行读出之后做判断了,根本没处理啊~~~~~~
//应该这样
while (inFile.ready ()){
System.out.print(inFile.readLine());
}

解决方案 »

  1.   

    import java.io.*;public class readFile {
      public static void main(String[] args) {
        try {
          BufferedReader inFile = new BufferedReader(new FileReader("D:\\a.txt"));
          String str =  inFile.readLine();
          while (str != null) {
            System.out.print(str);
          }
        }
        catch (Exception ex) {
          ex.getStackTrace();
        }
        System.out.println();
      }
    }
      

  2.   

    同一楼上的说法!
    private void openFileChoice()
    {
    choiceFile.showOpenDialog(choiceFrame);
    if(choiceFile.getSelectedFile()==null)
    {
    return;
    }
    try

    Reader in = new FileReader(choiceFile.getSelectedFile()); 
    char buffer[] = new char[8000];
    int nch;
    while((nch = in.read(buffer, 0, buffer.length)) != -1)

    enterMessage.append(new String(buffer, 0, nch)); 

    }
    catch (IOException choiceFileO)

    System.err.println(choiceFileO);
    }
    }这个是我写的一个记事本中的打开文件的一个方法!你可以参考一下!
      

  3.   

    因while (inFile.readLine()!=null){  //已经把世界你好!读了
    System.out.print(inFile.readLine()); //这里的已经是HelloWorld!
    }
      

  4.   

    import java.io.*;
    public class readFile{
    public static void main(String [] args){
    try
    {
       BufferedReader inFile=new BufferedReader(new FileReader("java.txt"));
       String tmp=null;
       while ((tmp=inFile.readLine())!=null)
       {
         System.out.print(tmp);
       }
    }
    catch(Exception ex)
    {
       ex.getStackTrace();
    }
    System.out.println();
    }
    }
    靠,晕!