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 ...
随机推荐
- Vijos1019 补丁VS错误[最短路 状态压缩]
描述 错误就是人们所说的Bug.用户在使用软件时总是希望其错误越少越好,最好是没有错误的.但是推出一个没有错误的软件几乎不可能,所以很多软件公司都在疯狂地发放补丁(有时这种补丁甚至是收费的).T公 ...
- OAuth2学习及DotNetOpenAuth部分源码研究
OAuth2学习及DotNetOpenAuth部分源码研究 在上篇文章中我研究了OpenId及DotNetOpenAuth的相关应用,这一篇继续研究OAuth2. 一.什么是OAuth2 OAuth是 ...
- Android应用更换package name以及ui refactoring error问题的有效解决
package name是Android系统中为每一个应用程序分配的一个标识,每个应用的标识都必须是不同的.在应用开发过程中,有时候可能需要对package name进行修改,这里主要总结修改pack ...
- HTML 学习笔记(表格)
HTML 表格 HTML中的表格使用标签<table>来实现,每个表格均有若干行由<tr>标签来定义,每个<tr>表示一行.美航被分为若干个单元格用<td&g ...
- http应用优化和加速说明-负载均衡
负载均衡技术 现代企业信息化应用越来越多的采用B/S应用架构来承载企业的关键业务,因此,确保这些任务的可靠运行就变得日益重要.随着越来越多的企业实施数据集中,应用的扩展性.安全性和可靠性也 ...
- C# 断点续传原理与实现
在了解HTTP断点续传的原理之前,让我们先来了解一下HTTP协议,HTTP协议是一种基于tcp的简单协议,分为请求和回复两种.请求协议是由 客户机(浏览器)向服务器(WEB SERVER)提交请求时发 ...
- Python的高级特性2:列表推导式,生成器与迭代器
一.列表推导式 1.列表推导式是颇具python风格的一种写法.这种写法除了高效,也更简短. In [23]: {i:el for i,el in enumerate(["one" ...
- ISAPI_Rewrite中文手册
参考:http://blog.csdn.net/fanxiaojie119/article/details/5353186 第一章:软件介绍ISAPI_Rewrite 是一款适用于IIS的功能强大的基 ...
- Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...
- mac里git项目删除.DS_Store文件
用mac开发项目,每次提交文件时都生成修改文件的.DS_Store文件,提交时会不会觉得比较烦?别急,下面给出解决方案.我们需要用到.gitignore文件去配置Git目录中需要忽略的文件. .git ...