My code fails at a certain point. Java File IO -


i new java. programmed in c++. trying work files code fails when try create file, is, when program tests if file exists, fails, have created file.

public schedule(string name, string event) {    string filename= name+event+".txt";    file timetable=new file(filename);    if (timetable.exists()&&timetable.isfile()){        writetofile(timetable,name,event,filename);       system.out.println("in constructor");    }//fails here  } 

i have created file

if following line reason saying this, you're wrong.

file timetable=new file(filename);

this making abstract representation of file/directory pathnames not make file if doesn't exist.

file timetable=new file(filename); timetable.createnewfile();

the createnewfile method make physical file if doesn't exist.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -