<span id="Label3"></p><p><p>The exception to the problem Is: Java.lang.illegalargumentexception:file/mnt/sdcard/crazyit.bin contains a Pathseparator.</p></p><p><p></p></p><p><p>The main reason is that the first parameter of the Openfileoutput () method used when opening the output stream of the file is used to specify the file name and cannot contain the path delimiter "/"<br>Workaround//fileinputstream FIS =<br>Openfileinput (sdcarddir.getcanonicalpath () +file_name); instead fileinputstream FIS = new<br>FileInputStream (sdcarddir.getcanonicalpath () +file_name)</p></p><p><p></p></p><p><p></p></p><p><p>There are two ways to read InputStream</p></p><p><p>1.inputstream---"byte---" String</p></p><p><p></p></p><p><p>2.inputstream--->inputstreamreader---->bufferedread-->string</p></p><p><p></p></p><p><p>Android SD file reading module</p></p><p>FileInputStream FileInputStream = null;<br>try {<br>File File = new file (environment.getexternalstoragedirectory ()<br>+ "/wipe.txt");<br><br>If (!file.exists ())<br>File.createnewfile ();<br>FileInputStream = new FileInputStream (file);<br>BufferedReader BufferedReader = new BufferedReader (<br>New InputStreamReader (fileinputstream));<br>String temapp;<br><br>While ((temapp = Bufferedreader.readline ()) = null) {<br><br>Apps.add (temapp);<br>Toast.maketext (mainactivity.this, temapp, Toast.length_long)<br>. Show ();<br>}<br>Bufferedreader.close ();<br><br>} catch (filenotfoundexception E) {<br>TODO auto-generated Catch block<br>E.printstacktrace ();<br>} catch (ioexception E) {<br>TODO auto-generated Catch block<br>E.printstacktrace ();<br>} finally {<br>If (fileinputstream! = Null)<br>try {<br>Fileinputstream.close ();<br>} catch (ioexception E2) {<br>Todo:handle exception<br>E2.printstacktrace ();<br>}<br>}</p><p><p>Android file path</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service