import java.io.*;
public class ReadFileDemo
{ public static void main(String[] args) throws java.io.IOException
{ byte b[]=new byte[64];
  try{ FileInputStream myFile=new FileInputStream("d:\\简介.txt");
       myFile.read(b);
       System.out.write(b);
}
catch(FileNotFoundException e){ System.out.println("File not find");}
catch(IOException e) {System.out.println("IO error");}
String s=new String(b);
System.out.println(s);
myFile.close();
}
}
编译不过,不知道问题再哪,请高手指教!

解决方案 »

  1.   

    给你个例子,希望对你有帮助:import java.io.*;public class Test {
      private File fileIn;
      private BufferedReader bRead;  public Test() {
        fileIn = new File("Test.java");
        try {
          bRead = new BufferedReader(new FileReader(fileIn));
        }
        catch (FileNotFoundException ex) {
        }
        String value = new String();
        try {
          while((value = bRead.readLine()) != null){
            System.out.println(value);
          }
        }
        catch (IOException e) {
        }
      }  public static void main(String[] args) {
        new Test();
      }}
      

  2.   

    你想实现个甚么功能/?
         读取文件,保存到String?
      

  3.   

    对,读取文件内容,保存到String ,然后显示.怎么不对那,很迷惑,不知道错在哪.