What exception is thrown while creating a file in java -


import java.io.bufferedwriter; import java.io.file; import java.io.filewriter; import java.io.ioexception; public class filewrite {     public static void main(string args[]) {         try{             string content="this world";             file f=new file("d:/abc.txt");         }catch(ioexception i) {             i.printstacktrace();         }     } } 

compilation of above code gives error:

io exception never thrown corresponding try block.  

what exception may thrown while creating file?

from java docs:

throws:
nullpointerexception - if pathname argument null

when want see exceptions being thrown method (constructor in case), can search in java docs, or if using eclipse ide, put cursor on method, , press f2.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -