i tried the following code but it gets stuck on String lineFromInput = in.readLine(); line and without this line , the txt file is empty.
the code i used is :
try
{
File file = new File("out.txt"); //Your file
FileOutputStream fos = new FileOutputStream(file);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String lineFromInput = in.readLine();
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
ps.println(lineFromInput);
// System.out.println("This goes to out.txt");
}
catch(IOException e)
{
System.out.println("Error during reading/writing");
}