• 将json文件转换为字符串


    //从给定位置读取Json文件
        public   String readJson(String path){
            //从给定位置获取文件
            File file = new File(path);
            BufferedReader reader = null;
            //返回值,使用StringBuffer
            StringBuffer data = new StringBuffer();
            //
            try {
                reader = new BufferedReader(new FileReader(file));
                //每次读取文件的缓存
                String temp = null;
                while((temp = reader.readLine()) != null){
                    data.append(temp);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                //关闭文件流
                if (reader != null){
                    try {
                        reader.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
            return data.toString();
        }

  • 相关阅读:
    换行的展示
    jsp页面的导出功能
    怎么设置回车键为提交功能?
    HBuilder使用心得
    js和jQuery
    前端常用技术总结--java程序员
    对压缩文件加密
    删除表中一个字段的SQL语句
    用NPOI操作EXCEL-锁定列CreateFreezePane()
    MVC 点击下载文档
  • 原文地址:https://www.cnblogs.com/yanduanduan/p/5412488.html
Copyright © 2020-2023  润新知