java - Setting path where we want to create file -


i have function prints 1 string in file. functions makes new file in project. want create new file in folder in src , called resources.

so should go project -> src -> resources -> foruser.txt

i tried got error "/src/resources/foruser.txt";

private void printtofile(string toprint) {     file f = new file("foruser.txt");       if(f.exists())         f.delete();      printwriter out = null;      try {         out = new printwriter(new filewriter(f,true));         out.println(toprint);     } catch (exception e) {         e.printstacktrace();     }     finally{         out.close();     } } 


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -