Please can someone advise if there is anything wrong with this code? It doesn't write anything to the file
import java.io.PrintWriter; public class writeToFile { static String filename = "te.txt"; public static void recorder() { try { PrintWriter writer = new PrintWriter(filename, "UTF-8"); int me = 1232132; writer.write(me); System.out.println("Written"); writer.close(); } catch(Exception e) { System.out.println("Error when writing file"); System.out.println(e.toString()); } } public static void main(String[] args) { // TODO Auto-generated method stub recorder(); } }
2.1m questions
2.1m answers
60 comments
57.0k users