zoukankan      html  css  js  c++  java
  • JAVA写入大文件DEMO

        /**
         * 读取filePath的文件
         * @param filePath    文件的路径
         * @return     List集合       文件中一行一行的数据
         */
        public static List<String > readToString(String filePath)
        {
            List<String > olist = new ArrayList<String>();
            File file = new File(filePath);
            Long filelength = file.length(); // 获取文件长度
            byte[] filecontent = new byte[filelength.intValue()];
            try{
                FileInputStream in = new FileInputStream(file);
                in.read(filecontent);
                in.close();
            } catch (Exception e){
                e.printStackTrace();
            }

            olist = Splitter.on(" ").trimResults().splitToList(new String(filecontent));

            return olist;// 返回文件内容,默认编码
        }

    你所拥抱的并不总是拥抱你
  • 相关阅读:
    request
    href="#"
    可展开收起的客服导航。
    JS添加父节点的方法。
    精简漂亮的导航浮动菜单显示特效演示
    竖排导航
    仿新浪微博
    鼠标滑过改变文字
    滚动函数
    一些常用的兼容函数。
  • 原文地址:https://www.cnblogs.com/java-h/p/10583794.html
Copyright © 2011-2022 走看看