• java 写文件


    FileName为要写入的文件路径
    AppendString为要写入文件的string
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public static void AppendFile(String FileName,String AppendString){
      BufferedReader reader = null;
      try {
       reader = new BufferedReader(new InputStreamReader(new FileInputStream(SysConfig.STATIC_INSTALLDATABASEINFO_PATH)));
      } catch (FileNotFoundException e1) {
       e1.printStackTrace();
      }
      StringBuffer buffer = new StringBuffer();
      String line=null;
      try {
       line = reader.readLine();
       while (line != null) {         
                 buffer.append(line);       
                 buffer.append("\n");       
                 line = reader.readLine();  
             }
      } catch (IOException e1) {
       e1.printStackTrace();
      }     
           
      BufferedWriter wr1;
      try {
       wr1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileName)));
       try {
        wr1.append(buffer);
        wr1.append(AppendString);
        wr1.newLine();
        wr1.flush();
        wr1.close();
       } catch (IOException e) {
        e.printStackTrace();
       }
      } catch (FileNotFoundException e) {
       e.printStackTrace();
      }
     }
     public static void WriteFile(String FileName,String WriteString){
      BufferedWriter wr1;
      try {
       wr1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileName)));
       try {
        wr1.append(WriteString);
        wr1.newLine();
        wr1.flush();
        wr1.close();
       } catch (IOException e) {
        e.printStackTrace();
       }
      } catch (FileNotFoundException e) {
       e.printStackTrace();
      }
     }
  • 相关阅读:
    高内聚,低偶合
    Infinite Scrolling in UIScrollView
    ios5开发UITableView开启编辑功能
    一种自动的将自定义类序列化为JSON的方法
    Beini Compatible Hardware List
    BizTalk开发小工具批量更新发送端口订阅配置参数
    IOS5开发http get/post调用mvc4 webapi互操作(图片上传)
    IOS5开发控件位置适应屏幕旋转代码
    打开WHRHPG54AP的HP(High Power)功能
    xcode uiscrollview with paging and zoom
  • 原文地址:https://www.cnblogs.com/kentyshang/p/856981.html
Copyright © 2020-2023  润新知