java - I can't create the file -
what wrong coding? tried create file name & printout in text file package practical12;
import java.io.filenotfoundexception; import java.io.printwriter; import java.util.scanner; public class q4 { public static void main (string []args) throws filenotfoundexception{ system.out.println("please input file name"); string name; //take file name scanner in; in = new scanner(system.in); name = in.nextline(); printwriter out = new printwriter(name); // create textfile out.println("hello! first program in file"); // write text out.close(); //close file } }
if entered name of file instead of absolute path, created in current working directory of program. in order check current working directory using java please check getting current working directory in java
Comments
Post a Comment