zoukankan      html  css  js  c++  java
  • java读取本地文件

    File file = new File("F:/hejing/InstrumentJsonData.txt");
            StringBuilder localStrBulider = new StringBuilder();
            if(file.isFile() && file.exists()) {
                try {
                    InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), "utf-8");
                    BufferedReader bufferReader = new BufferedReader(inputStreamReader);
                    String lineStr = null;
                    try {
                        while((lineStr = bufferReader.readLine()) != null) {
                            localStrBulider.append(lineStr);
                        }
                        bufferReader.close();
                        inputStreamReader.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        System.out.println("file read error!");
                        e.printStackTrace();
                    }
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    System.out.println("file catch unsupported encoding!");
                    e.printStackTrace();
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    System.out.println("file not found!");
                    e.printStackTrace();
                }
            }else {
                System.out.println("file is not a file or file is not existing!");
                return null;
            }
            System.out.println("localStrBulider.toString():" + localStrBulider.toString());

  • 相关阅读:
    如何在XSLT中实现勾选的效果
    6个jQuery图表Web应用扩展
    数据仓库(集市)之间共享维度表
    Json.NET
    jquery调用页面的方法
    使用javascript打开模态对话框
    使用ApplicationDeployment 类以编程方面对ClickOnce程序进行更新 【转载】
    XSLT 编译器 (xsltc.exe)
    在xslt中添加链接的方式
    哀悼
  • 原文地址:https://www.cnblogs.com/hejing-swust/p/7986593.html
Copyright © 2011-2022 走看看