this is my code...in my code i cant give input form my console...it takes input but it doesn't save in a target file...Anybody can help me ?
My code is :-
package filetester; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class tester { public static void main(String[] args) { File inpfile = new File("C:/Users/abid/Desktop/1.txt"); File outfile = new File("C:/Users/abid/Desktop/2.txt"); // i want a output file name 2 try { FileReader readfile = new FileReader(inpfile); try { FileWriter writefile = new FileWriter(outfile); Scanner myScanner = new Scanner(System.in); while (myScanner.hasNext()) { String temp = myScanner.nextLine(); //System.out.println(temp); writefile.write(temp +"\n"); // i want to write named 2 file through console , but it doesnt work .. } readfile.close(); writefile.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); System.out.println("no file found"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }