zoukankan      html  css  js  c++  java
  • 追加模式 文件读写

    1.方法一

    try{

      RandomAccessFile randomFile = new RandomAccessFile(path,"rw");

      long fileLength = randomFile.length();

      randomFile.seek(fileLength);

      String str;

      //为了解决乱码问题做如下变换

      byte temp[] = str.getBytes();

      randomFlie.write(temp);

      randomFile.close;

    }catch(IOExcteption e){

      e.printStackTrace();

    }

    2.方法二

     public static void appendMethodB(String fileName, String content) {
            try {
                //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
                FileWriter writer = new FileWriter(fileName, true);
                writer.write(content);
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    //补充   以空格把字符串分成若干个

    String strLine;
    Scanner in = new Scanner(System.in);
    strLine = in.nextLine();
    String str[] = strLine.split(" "); 从0开始

  • 相关阅读:
    JSP详细解析
    JSP详细解析
    JAVA设计模式之单例模式
    JAVA设计模式之单例模式
    SQLite – GLOB子句
    HEXO进阶打赏
    python常用模块
    猫头鹰的深夜翻译:核心JAVA并发一
    标准规范
    题解 P1951 【收费站_NOI导刊2009提高(2)】
  • 原文地址:https://www.cnblogs.com/xiaochi/p/4933972.html
Copyright © 2011-2022 走看看