// test to read a text file
    System.out.println("Please input the path of file");
    System.out.print("# ");
    InputStreamReader myin = new InputStreamReader(System.in);
    char FileInputPath[] = new char[14];
    try {
      myin.read(FileInputPath); // samples: E:/pan/pan.txt
      //FileInputPath[14] = '\u0000';
      String path = new String(FileInputPath);
      System.out.println(path);
      FileReader myfile = new FileReader(path);
      BufferedReader myfilein = new BufferedReader(myfile);
      String line = new String();      if (myfilein.ready())
        line = myfilein.readLine();
      System.out.println(line);
    }
    catch (IOException e) {
      System.out.println("Get the end of the file");
    }
  }E:/pan/pan.txt
first line: Hello!
result: Hello!
我知道问题出在文件路径的正确性上,但是我不知道字符串的结束府在Unicode种是多少。但是只要文件明的长度跟上面数组的长度一样就可以得到结果。