Loading
Not able to read a file

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  Are you not able to read a file ?, how to solve ?


Ans)

There are two possible solutions for this.

i) If you want to do this by using java.IO package , you just need share the Folder and make sure that this file (the folder from which you are reading
   that file)is accessible to JVM.

ii) If not , you want to do this by reading this file a resource, please do the following.
       a) Add the file(Folder which contains the Folder) to the class path and read using file API.
       b) Use getClassLoader() method of "Class" to load the File as a resource as shown below, this method looks for the file in Classpath.
   
   getClass().getClassLoader().getResource("Configuration.properties").getFile();



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Not able to read a file


Not able to read a file

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free