java - Writing Contents of TextArea to File -
i'm converting old applications in java use "j" components newer, more trendy javafx platform.
previously in 1 of application, able write contents of textarea file,nicely spaced indented, graphically saw in text area. did using write() method jtextarea class inherited.
is there anyway javafx text area, or can able parse through file , way?
assistance appreciated!
code used in jtextarea write files:
public static void writefile(file filename) throws ioexception{ bufferedwriter fileout = new bufferedwriter(new filewriter(filename)); gui.gettextarea().write(fileout); }
you can iterating on text area , writing contents file:
observablelist<charsequence> paragraph = textarea.getparagraphs(); iterator<charsequence> iter = paragraph.iterator(); try { bufferedwriter bf = new bufferedwriter(new filewriter(new file("textarea.txt"))); while(iter.hasnext()) { charsequence seq = iter.next(); bf.append(seq); bf.newline(); } bf.flush(); bf.close(); } catch (ioexception e) { e.printstacktrace(); }
Comments
Post a Comment