android file path
问题 出现的异常为:java.lang.IllegalArgumentException: File /mnt/sdcard/crazyit.bin contains a pathseparator。
主要是由于在打开文件的输出流时使用的openFileOutput()方法的第一参数用于指定文件名称,不能包含路径分隔符“/”
解决方法 // FileInputStream fis =
openFileInput(sdCardDir.getCanonicalPath()+FILE_NAME);改为 FileInputStream fis = new
FileInputStream(sdCardDir.getCanonicalPath()+FILE_NAME)
对于InputStream的读取有两种方法
1.inputstream---》byte---》String
2.inputstream--->inputstreamReader---->BufferedRead-->string
android之sd文件读取模块
FileInputStream fileInputStream = null;
try {
File file = new File(Environment.getExternalStorageDirectory()
+ "/wipe.txt");
if (!file.exists())
file.createNewFile();
fileInputStream = new FileInputStream(file);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(fileInputStream));
String temapp;
while ((temapp = bufferedReader.readLine()) != null) {
apps.add(temapp);
Toast.makeText(MainActivity.this, temapp, Toast.LENGTH_LONG)
.show();
}
bufferedReader.close();
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} finally {
if (fileInputStream != null)
try {
fileInputStream.close();
} catch (IOException e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
android file path的更多相关文章
- 安卓各文件存储路径汇总(Android file path)
写下来,省得以后不记得到处翻: Environment.getDataDirectory() = /data Environment.getDownloadCacheDirectory() = /ca ...
- 《ArcGIS Runtime SDK for Android开发笔记》——问题集:Error:Error: File path too long on Windows, keep below 240 characters
1.前言 在使用Android Studio开发环境时,经常会爆出以下错误,虽然具体细节内容各有不同,但是说明的都是同一个问题,在windows中使用过长的路径,超过240字符. Error:Erro ...
- Android File Hierarchy : System Structure Architecture Layout
Most of the Android user are using their Android phone just for calls, SMS, browsing and basic apps, ...
- [LeetCode] Longest Absolute File Path 最长的绝对文件路径
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsub ...
- Android中Path类的lineTo方法和quadTo方法画线的区别
转载:http://blog.csdn.net/stevenhu_223/article/details/9229337 当我们需要在屏幕上形成画线时,Path类的应用是必不可少的,而Path类的li ...
- Longest Absolute File Path
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsub ...
- android 利用Path.cubicTo 画 贝塞尔曲线
Path.cubicTo void android.graphics.Path.cubicTo(float x1, float y1, float x2, float y2, float x3, fl ...
- OS X 禁止Android File Transfer自动启动
操作步骤 关闭Android File Manager 在Activity Manager中退出Android File Manager Agent进程 在Applications中,将Android ...
- Leetcode: Longest Absolute File Path
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsub ...
随机推荐
- 白话debounce和throttle
遇到的问题 在开发过程中会遇到频率很高的事件或者连续的事件,如果不进行性能的优化,就可能会出现页面卡顿的现象,比如: 鼠标事件:mousemove(拖曳)/mouseover(划过)/mouseWhe ...
- [译] 企业级 OpenStack 的六大需求(第 1 部分):API 高可用、管理和安全
全文包括三部分: 第一部分:API 高可用和管理以及安全模型 第二部分:开放架构和混合云兼容 第三部分:弹性架构和全球交付 引言 OpenStack 是构造企业级私有云的非常理想的基础.它立志成为新一 ...
- Java Web之会话技术
客户端与服务器通信过程中,会产生一些数据.比如,A和B分别登陆了某宝购物网站,A买了一个Android手机,B买了一个iPhone手机,当结账时,web服务器需要分别对用户A和B的信息分别保存.根据J ...
- Golang tips
1.go test 测试单个函数 go test -v -test.run Test* 2.
- POJ1155TELE[树形背包]
TELE Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4957 Accepted: 2726 Description ...
- Java深入 - Java 内存分配和回收机制
Java的GC机制是自动进行的,和c语言有些区别需要程序员自己保证内存的使用和回收. Java的内存分配和回收也主要在Java的堆上进行的,Java的堆中存储了大量的对象实例,所以Java的堆也叫GC ...
- [No00001C]不想背单词患者的福音!-快来定制你的个性词包-不想记、记不牢,这可怎么办?
肯定有朋友觉得我像是在给百词斩做广告一样,其实我可没拿到他们一分钱哦.不过好东西就是要分享,这才是互联网最有价值的地方. 点击下载百词斩
- stl学习(二)集合 set 的使用
set集合容器底层由红黑树实现,是平衡二叉搜索树. 相对stl中的list.deque效率更高. 注意:由于集合 的 性质,单纯的 set 不允许重复的元素 初始化 / 清空 函数 : clear() ...
- Java读写文本文件
1 字符输入(FileReader , char) import java.io.IOException; import java.io.FileReader; public class ep10_1 ...
- 04传智_jbpm与OA项目_部门模块改进_直接在BaseAction中实现ModelDriven<T>
这个项目是用Struts2做的,我这里单独写了一个BaseAction,用来存放所有的功能模块的Action的公共部分, 刚开始的做法是这个BaseAction只会继承ActionSupport 并不 ...