源码:
import java.io.*;
class inread{
public static void mian(String args[])
{
FileInputStream fis = new FileInputStream("c:\s.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
System.out.println(s);
br.close();
}
}
错在哪啊
--------------------Configuration: <Default>--------------------
C:\inread.java:5: illegal escape character
                FileInputStream fis = new FileInputStream("c:\s.txt");
                                                              ^
1 errorProcess completed.

解决方案 »

  1.   

    FileInputStream fis = new FileInputStream("c:\s.txt");
    应该是:
    FileInputStream fis = new FileInputStream("c:\\s.txt");
    或者
    FileInputStream fis = new FileInputStream("c:/s.txt");
      

  2.   

    现在错越来越多了,
    --------------------Configuration: <Default>--------------------
    C:\inread.java:5: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
                    FileInputStream fis = new FileInputStream("c:\\s.txt");
                                          ^
    C:\inread.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
    String s = br.readLine();
                          ^
    C:\inread.java:10: unreported exception java.io.IOException; must be caught or declared to be thrown
    br.close();
            ^
    3 errors
      

  3.   

    没抛出异常~
    在你的方法后面加个 throws Exception

    public static void main(String args[]) throws Exception
    {}