Android文本读写
//写文件操作
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文本读写的更多相关文章
- [转]Android - 文件读写操作 总结
转自:http://blog.csdn.net/ztp800201/article/details/7322110 Android - 文件读写操作 总结 分类: Android2012-03-05 ...
- 文本读写vs二进制读写
[文本读写vs二进制读写] 在学习C语言文件操作后,我们都会知道打开文件的函数是fopen,也知道它的第二个参数是 标志字符串.其中,如果字符串中出现'b',则表明是以打开二进制(binary)文件, ...
- 在android中读写文件
在android中读写文件 android中只有一个盘,正斜杠/代表根目录. 我们常见的SDK的位置为:/mnt/sdcard 两种最常见的数据存储方式: 一.内存 二.本地 1.手机内部存储 2.外 ...
- Python对文本读写的操作方法【源码】
Dear ALL 今天给大家分享的是 TXT文本读写方式,也是文件操作最常用的一种方式,主要内容有: 文件写方法 文件读方法 with open() as f 方法 话不多说,码上见: ''' 标题: ...
- android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()
最终效果图,点击save会保存到文件中,点击show会从文件中读取出内容并显示. main.xml <?xml version="1.0" encoding=" ...
- 【Android】android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()
最终效果图,点击save会保存到文件中,点击show会从文件中读取出内容并显示. main.xml <?xml version="1.0" encoding="ut ...
- android adb 读写模式 挂载文件系统
http://www.qylk.blog.163.com/blog/static/1346873562013092154430/ http://blog.sina.com.cn/s/blog_9906 ...
- Android 文件读写
一.分类 文件读写作为Android四大数据存储方式之一,又分为内部存储和外部存储两种: (1)内部存储(Internal storage): 总是可用. 文件默认情况存储在/data/data/包名 ...
- Android文本输入框(EditText)切换密码的显示与隐藏
package cc.c; import android.app.Activity; import android.os.Bundle; import android.text.Selection; ...
随机推荐
- javascript 代码可读性
可读性的大部分内容都是和代码缩进相关的,必须保证代码有良好的格式.可读性的另一方面就是注释,一般而言,有如下一些地方需要进行注释 1.1.1 函数和方法 每个函数或方法都应该包含一个注释,描述其目的和 ...
- $(document).ready、body.Onload()和 $(window).load的区别
window.load(function(){...})和body.onload()都存在同样一个问题,那都是在页面所有元素(包括html标签以及引用到得所有图片,Flash等媒体)加载完毕后执行的, ...
- R树空间索引及其变种
1.R树及其变种:百度百科 2.R树详介:http://blog.csdn.net/jazywoo123/article/details/7792745 3.R树及变种小结 R树:叶子节点或中间节点都 ...
- Numerical Optimization: Understanding L-BFGS
http://aria42.com/blog/2014/12/understanding-lbfgs/ Numerical optimization is at the core of much of ...
- Order Independent Transparency
http://on-demand.gputechconf.com/gtc/2014/presentations/S4385-order-independent-transparency-opengl. ...
- OpenGL教程
http://www.opengl-tutorial.org/ http://www.lighthouse3d.com/ http://www.arcsynthesis.org/gltut/ http ...
- Robot Framework--08 List Variables-List变量及其用法
转自:http://blog.csdn.net/tulituqi/article/details/7907981 一.List变量及其用法 在我们前面几篇文章里用到了很多List变量,相信以后各位也会 ...
- The length of the string value exceeds the length configured in the mapping/parameter.
在NHibernate 3.3 中存储的字符串太长,会抛异常:The length of the string value exceeds the length configured in the m ...
- [LeetCode] Longest Valid Parentheses
第一种方法,用栈实现,最容易想到,也比较容易实现,每次碰到‘)’时update max_len,由于要保存之前的‘(’的index,所以space complexity 是O(n) // 使用栈,时间 ...
- 安装 SQL server 2008 R2
操作系统:WIN7 问题: The Windows Installer Service could not be accessed. This can occur if the Windows Ins ...