wylblogs

java一次读取文本文件所有内容

public String readToString(String fileName) {  
        String encoding = "UTF-8";  
        File file = new File(fileName);  
        Long filelength = file.length();  
        byte[] filecontent = new byte[filelength.intValue()];  
        try {  
            FileInputStream in = new FileInputStream(file);  
            in.read(filecontent);  
            return new String(filecontent, encoding);
        } catch (Exception e) {  
            e.printStackTrace();  
       return null; } finally { in.close; } }
发表于 2018-03-09 14:51  CityOfMemories  阅读(8186)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2022-01-16
  • 2021-11-27
  • 2022-02-17
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案