Java读取文件内容并转换为字符串
String FileName="d:/2.txt";
File myFile=new File(FileName);
if(!myFile.exists())
...{
System.err.println("Can't Find "+ FileName);
}
try
...{
BufferedReader in =new BufferedReader(new FileReader(myFile));
String str;
while ((str = in.readLine()) !=null)
...{
System.out.println(str);
}
in.close();
}
catch (IOException e)
...{
e.getStackTrace();
}