java input/ output file problems -
the aim here method create file if not exist if exists : open , modify it... errors createnewfile() not member of class, exist() not member of class..i imported java.io.* post snippet..i hightlight problems comments quicker help...
public void writecoordtofile () throws ioexception { file file = new file("fermipresentcoord.txt"); // boolean yes = createnewfile("fermipresentcoord.txt") throws ioexception; error when try //boolean yes = exists("fermipresentcoord.txt"); error exists not member of file // creates file file.createnewfile(); // creates filewriter object filewriter writer = new filewriter(file); // writes content file writer.write(pos_let); writer.write(pos_num); writer.flush(); writer.close(); }
you need give file
object, createnewfile()
method of file
class. function's of class can accessed using file's object(file).methodname()
file file = new file("fermipresentcoord.txt"); boolean yes = file.createnewfile() boolean yes1 = file.exists();
Comments
Post a Comment