RomeScape

Programming => Java => Topic started by: Mazead on October 11, 2014, 06:43:15 pm



Title: JEditorPane text file as html
Post by: Mazead on October 11, 2014, 06:43:15 pm
I would like my JEditorPane to process any text file as html file.

Quote
String file = "cube.obj";
JEditorPane t = new JEditorPane();
t.setEditable(true);
try {
   URL url = new URL(getCodeBase(), file);
   t.setPage(url);
} catch (NumberFormatException | IOException e) {
   e.printStackTrace();
}


Is it possible? My first idea was to read my text file line by line and add these lines to editor pane, but is there any more "elegant" solution?