I tried to run the same on my system and it did produce the output file. The code I used is :
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Scanner;
public class ScannerTest {
public static void main(String[] args) {
File file = new File("C:///YServer.txt");
Scanner scanner = null;
PrintWriter pw = null;
try {
scanner = new Scanner(file);
pw = new PrintWriter(new FileWriter("C:///scanneroutput.txt"));
while (scanner.hasNextLine()) {
String l = scanner.nextLine();
// System.out.println(l);
pw.print(l);
}
} catch (Exception e) {
} finally {
System.out.println("Out File Generated.");
if (scanner != null) {
scanner.close();
}
}
}//end of main method
}