我有一个文件名,在我的code为:
字符串NAME_OF_FILE =// SD卡// imageq.png;
的FileInputStream FIS = this.openFileInput(NAME_OF_FILE); //二号线
我得到第2行错误:
05-11 16:49:06.355:ERROR / AndroidRuntime(4570):java.lang.IllegalArgumentException异常:产生的原因文件//sdcard//imageq.png包含路径分隔符
我想这个格式还:
字符串NAME_OF_FILE =/ SD卡/ imageq.png;
解决方案
这个方法打开应用程序的私有数据区中的文件。你不能在此区域或使用此方法完全其它领域打开子目录中的任何文件。所以,使用的FileInputStream
或此类。
I have a filename in my code as :
String NAME_OF_FILE="//sdcard//imageq.png";
FileInputStream fis =this.openFileInput(NAME_OF_FILE); // 2nd line
I get an error on 2nd line :
05-11 16:49:06.355: ERROR/AndroidRuntime(4570): Caused by: java.lang.IllegalArgumentException: File //sdcard//imageq.png contains a path separator
I tried this format also:
String NAME_OF_FILE="/sdcard/imageq.png";
解决方案
This method opens a file in the private data area of the application. You cannot open any files in subdirectories in this area or from entirely other areas using this method. So use a FileInputStream
or such.