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();
}
}
编译不过,不知道问题再哪,请高手指教!
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();
}
}
编译不过,不知道问题再哪,请高手指教!
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();
}}
读取文件,保存到String?