Given a Scanner reference variable, stdin, that is associated with standard input, read in two words. Use the first word as the name of a file to create and store the second word in. Make sure that the data written to the file has been flushed from its buffer and that any system resources used during the course of running these statements have been released. (Do not concern yourself with any possible exceptions here– assume they are handled elsewhere.)

LANGUAGE: JAVA

CHALLENGE:

Given a Scanner reference variable, stdin, that is associated with standard input, read in two words. Use the first word as the name of a file to create and store the second word in. Make sure that the data written to the file has been flushed from its buffer and that any system resources used during the course of running these statements have been released. (Do not concern yourself with any possible exceptions here– assume they are handled elsewhere.)

SOLUTION:


String a = new String(stdin.next());
String b = new String(stdin.next());

File f = new File(a);
PrintWriter pw = new PrintWriter(f);
pw.print(b);
pw.close();