Java: PrintWriter object not detected -
i having trouble getting java recognize printwriter object 'out'. i'm not sure problem is.
public void storeinput(string filename) { string foldername = "c:/temper/testy/"; file filetest = new file(foldername, filename); system.out.println("enter text!!!!!"); string input = sc.nextline(); try { printwriter out = new printwriter( new bufferedwriter( new filewriter(filetest))); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } out.println(filetest); out.close(); }
declare outside of try
printwriter out = null; try { out = new printwriter( new bufferedwriter( new filewriter(filetest))); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
Comments
Post a Comment