//写文件操作
   public void writeFileData(String fileName, String message){
        try{
            FileOutputStream fout = openFileOutput(fileName, MODE_PRIVATE);
            byte[] bytes = message.getBytes();
            fout.write(bytes);
            fout.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

//读文件操作
    public String readFileData(String fileName){
        String res = "";
        try {
            FileInputStream fin = openFileInput(fileName);
            int length = fin.available();
            byte[] buffer = new byte[length];
            fin.read(buffer);
            res = EncodingUtils.getString(buffer, "UTF-8");
            fin.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return res;
    }

Android文本读写的更多相关文章

  1. [转]Android - 文件读写操作 总结

     转自:http://blog.csdn.net/ztp800201/article/details/7322110 Android - 文件读写操作 总结 分类: Android2012-03-05 ...

  2. 文本读写vs二进制读写

    [文本读写vs二进制读写] 在学习C语言文件操作后,我们都会知道打开文件的函数是fopen,也知道它的第二个参数是 标志字符串.其中,如果字符串中出现'b',则表明是以打开二进制(binary)文件, ...

  3. 在android中读写文件

    在android中读写文件 android中只有一个盘,正斜杠/代表根目录. 我们常见的SDK的位置为:/mnt/sdcard 两种最常见的数据存储方式: 一.内存 二.本地 1.手机内部存储 2.外 ...

  4. Python对文本读写的操作方法【源码】

    Dear ALL 今天给大家分享的是 TXT文本读写方式,也是文件操作最常用的一种方式,主要内容有: 文件写方法 文件读方法 with open() as f 方法 话不多说,码上见: ''' 标题: ...

  5. android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()

      最终效果图,点击save会保存到文件中,点击show会从文件中读取出内容并显示. main.xml <?xml version="1.0" encoding=" ...

  6. 【Android】android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()

    最终效果图,点击save会保存到文件中,点击show会从文件中读取出内容并显示. main.xml <?xml version="1.0" encoding="ut ...

  7. android adb 读写模式 挂载文件系统

    http://www.qylk.blog.163.com/blog/static/1346873562013092154430/ http://blog.sina.com.cn/s/blog_9906 ...

  8. Android 文件读写

    一.分类 文件读写作为Android四大数据存储方式之一,又分为内部存储和外部存储两种: (1)内部存储(Internal storage): 总是可用. 文件默认情况存储在/data/data/包名 ...

  9. Android文本输入框(EditText)切换密码的显示与隐藏

    package cc.c; import android.app.Activity; import android.os.Bundle; import android.text.Selection; ...

随机推荐

  1. PHP之:随机抽取一个数&&随机函数

    撰写日期:2016-7-20 16:00:24 有5个数:1 4 7 9 6 用PHP实现随机抽取5个数中的其中一个 方法一: <?php $test = array(1,4,7,9,6);// ...

  2. Linux下串口编制【转】

    串行口是计算机一种常用的接口,具有连接线少,通讯简单,得到广泛的使用.常用的串口是RS-232-C接口(又称EIA RS-232-C)它是在1970年由美国电子工业协会(EIA)联合贝尔系统.调制解调 ...

  3. 过滤字符串的Html标记 c#函数 .

    .public static string StripHTML(string strHtml) . { . string[] aryReg ={ . @"<script[^>]* ...

  4. restClient访问SSL

    IRestClient client = new RestClient("https://xxx.com/aa/bb"); "; ); ServicePointManag ...

  5. sphinx :undefined reference to `libiconv' 报错解决办法

    sphinx :undefined reference to `libiconv' 报错解决办法   2013-11-30 21:45:39 安装sphinx时不停报错...郁闷在make时报错,错误 ...

  6. Unable to find vcvarsall.bat的解决办法

    明年绝对买MAC电脑,这一两天安装paramiko,真是操碎了心. 安装paramiko时报error: Unable to find vcvarsall.bat这种错误,网上找了各种方法啊,解决的办 ...

  7. OpenGL Driver Architecture[转]

    http://www.cnblogs.com/cgwolver/archive/2009/01/04/1368350.html

  8. django笔记-模型数据模板呈现过程记录(多对多关系)

    首先,推荐一个网址:http://www.tuicool.com/articles/BfqYz2F,因为这里的比我的要有条理,更有利于各位的理解. 以下仅为为个人一次不完整的笔记: 环境:ubuntu ...

  9. jquery 判断网络图片,或网络文件是否存在

    $.ajax({ url : picSrc, async : false, type : 'HEAD', error : function() { picSrc = "https://ss0 ...

  10. idea引用自己的插件