`
xumingrencai
  • 浏览: 1183436 次
文章分类
社区版块
存档分类
最新评论

Java读取文件内容并转换为字符串

 
阅读更多

Java字符串与文件相互转换工具(一个非常实用的工具类)

转载自:http://lavasoft.blog.51cto.com/62575/d-7

Java读取文件内容并转换为字符串

转载自:http://blog.csdn.net/longronglin/article/details/1402267

StringFileName="d:/2.txt";
FilemyFile=newFile(FileName);
if(!myFile.exists())
{
System.err.println("Can'tFind"+FileName);
}


try
{
BufferedReaderin=newBufferedReader(newFileReader(myFile));
Stringstr;
while((str=in.readLine())!=null)
{
System.out.println(str);
}

in.close();
}

catch(IOExceptione)
{
e.getStackTrace();
}

测试通过


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics