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
Post a Comment