filename = "E:\\1.txt";

解决方案 »

  1.   

    Sam1983(Sam Lau):对
    "\"是转义字符,要得到字符"\"要用"\\"
      

  2.   

    帮你搞定:把你的代码改为下面的代码:
    import java.io.*;
    class ShowFile{
    public static void main(String args[])throws IOException

    {
    int i;
    String filename;
    filename = "E:\\1.txt";
    FileInputStream fin;
    try{
    fin = new FileInputStream(filename);

                        catch(FileNotFoundException e){
       System.out.println("File Not Found");
       return;
      }
                      
    do{
    i = fin.read();
    if(i != -1) System.out.print((char) i);
    }while(i != -1);
    fin.close();
    }
    }e盘目录建1.txt    1.txt写点东西就可以编译出来了
      

  3.   

    import java.io.*;
    class ShowFile{
    public static void main(String args[])throws IOException

    {
       int i;
    String filename;
    // filename = "E:\1.txt";
                      filename = "E:\\1.txt";
    FileInputStream fin;
    try{
    fin = new FileInputStream(filename);
    } catch(FileNotFoundException e){
       System.out.println("File Not Found");
       return;
      }catch(ArrayIndexOutOfBoundsException e){
        System.out.println("Usage: ShowFile File");
        return;
       }
    do{
    i = fin.read();
    if(i != -1) System.out.print((char) i);
    }while(i != -1);
    fin.close();
    }