zoukankan      html  css  js  c++  java
  • java工程生成jar,配置文件放在jar外面,读写配置文件

    public class Resource {
        public static void main(String[] args) {
            writeFile("562");
            readFileByChars();
        }
    
        public static void writeFile(String news_id) {
            FileOutputStream fsOut = null;
            String filePath = System.getProperty("user.dir")
                    + "/conf/newsid.txt";
            try {
                fsOut = new FileOutputStream(filePath);
                byte[] b1 = news_id.getBytes();
                fsOut.write(b1);
                fsOut.close();
                System.out.println(news_id+"写入CT成功!");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    fsOut.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
    
        }
    
        public static String readFileByChars() {
            String weixinid = "";
            String filePath = System.getProperty("user.dir")
                    + "/conf/newsid.txt";
            Reader reader = null;
            try {
                reader = new InputStreamReader(new FileInputStream(filePath));
                int tempchar;
                while ((tempchar = reader.read()) != -1) {
                    if (((char) tempchar) != '
    ') {
                        // System.out.print((char) tempchar);
                        weixinid += (char) tempchar + "";
                    }
                }
                reader.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    reader.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            return weixinid;
        }
    }


  • 相关阅读:
    swift关键字
    Swift开发注意点
    Mac上安装lua
    Runtime运行时机制
    ios开发中如何选择图片的加载方式
    ios开发中的静态内存分析
    loadrunner-2-9添加事务
    loadrunner-2-8HTML和URL模式
    loadrunner-2-7设置关联
    loadrunner中Windows Resource没有数据或不可用
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317841.html
Copyright © 2011-2022 走看看