Android java. io. IOException exception, androidexception

Source: Internet
Author: User

Android java. io. IOException exception, androidexception
Preface currently, most projects on android are developed by JAVA, and one of the most common exceptions in java is java. io. IOException, which we often encounter during android development. Here we have sorted out some common IOException situations in the Android development method. However, in reality, there may be a variety of causes for IOException, I have only sorted out several items here. You are welcome to leave a message for discussion.
Open failed: EACCES (Permission denied)

According to the error message, the cause is a permission error. The solutions are as follows:

1. Add the <uses-permission android: name = "android. permission. WRITE_EXTERNAL_STORAG"/> permission to AndroidMainfest. xml;
2. If not, add the <uses-permission android: name = "android. permission. MOUNT_UNMOUNT_FILESYSTEMS"/> permission to AndroidMainfest. xml;
3. Note the permission writing location in the AndroidMainfest. xml file: The permission should be at the same level as the <application> label node, rather than the <application> label, so that the permission will not take effect;
4. another exception was found when I checked the information. Some mobile phones temporarily lose the read and write permissions on sdcard/external storage when connecting to the computer in disk mode, in this case, an IOException occurs when the mobile app is opened.


Open failed: EISDIR (Is a directory)

This exception indicates that the program should operate on a file, and you pass in the program as a folder object.


Java. ioException: No such file or directory indicates that the file specified by the program to read and write does not exist, or the directory and file do not have the read and write permissions, for example: the app has its own/data/packagename/directory and file read and write permissions, but it does not have the read and write permissions for directories and files under other packages, unless your app has the root permission.

Android exception javaioException: No such file or directory

/Data/a. ioTest. test. run/
Does this directory exist?
Are you authorized to create files in this directory?

Java ioioexception that has not been reported; it must be captured or declared to throw

Public static void main (String args []) throws IOException {// you wrote an error here
ObjectInputStream jin = new ObjectInputStream (System. in );
Double tsampled = Double. valueOf (args [0]); // you have written an error in this method, and it seems that the array subscript is also incorrect.
While (tsampled! = Double. NaN ){
System. out. print (Double. valueOf (tsampled ));
System. out. print (Math. getExponent (Double. valueOf (tsampled )));
Tsampled = jin. readDouble ();
}
}

Only check syntax, no other check

This is the code written according to your needs (your requirements I understand ):

Public static void main (String args []) throws IOException {
BufferedReader reader = new BufferedReader (new InputStreamReader (
System. in ));
String line = reader. readLine ();

While (line! = Null ){

Double tsampled = Double. valueOf (line );
System. out. println (tsampled );
System. out. println (Math. getExponent (tsampled ));
Line = reader. readLine ();
}
}

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.