zoukankan      html  css  js  c++  java
  • Android中写文本文件的方法

           下面是我在Android开发中,一个写文本文件的方法,代码如下:

    //将字符串写入到文本文件中
        public static void WriteTxtFile(String strcontent,String strFilePath)
        {
          //每次写入时,都换行写
          String strContent=strcontent+"\n";
          try {
               File file = new File(strFilePath);
               if (!file.exists()) {
                Log.d("TestFile", "Create the file:" + strFilePath);
                file.createNewFile();
               }
               RandomAccessFile raf = new RandomAccessFile(file, "rw");
               raf.seek(file.length());
               raf.write(strContent.getBytes());
               raf.close();
          } catch (Exception e) {
               Log.e("TestFile", "Error on write File.");
              }
        }


  • 相关阅读:
    物理机连接虚拟机中的sqlserver
    Vue.js
    拆分时间段
    System.Threading.Timer
    浏览器被恶心页面占用
    sqlserver超时时间已到
    几年没写CSS
    C#生成高清缩略图
    抽奖概率算法
    html 页面实现指定位置的跳转
  • 原文地址:https://www.cnblogs.com/kevinGao/p/2426890.html
Copyright © 2011-2022 走看看