Re: JEditorPane question
Huh.
When I open LoremIpsum the \r\n pairs are there.
When I copy/paste from the console to a hex editor they're gone.
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.text.DefaultEditorKit;
public class JEditorPaneTest {
JFrame frame = null;
public static void main(String[] a)
throws FileNotFoundException, UnsupportedEncodingException {
(new JEditorPaneTest()).test();
}
private void test() throws FileNotFoundException,
UnsupportedEncodingException {
frame = new JFrame("JEditorPane Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,200);
JEditorPane pane = new JEditorPane();
pane.setContentType("text/plain");
pane.setText(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n"
+"Nunc pellentesque quam et justo fringilla, eu gravida nunc
tempus.");
pane.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty,
"\r\n");
System.out.println(pane.getText());
new PrintWriter("LoremIpsum",
"UTF-8").printf(pane.getText()).close();
frame.setContentPane(pane);
frame.setVisible(true);
}
}