JTextPane editor= new JTextPane();
try {
editor.setContentType("text/html");
BufferedReader br= new BufferedReader (new FileReader("fichero")); //tambien con URL.getContent()
StringBuffer sb= new StringBuffer();
String txt= null;
String newline = System.getProperty("line.separator");
while ((txt=br.readLine()) != null){
sb.append(txt);
sb.append(newline);
}
editor.setText(sb.toString());
System.out.println(editor.getText());
System.out.println("***********************");
editor.selectAll();
System.out.println(editor.getSelectedText());
System.out.println("***********************");
} catch (Exception e){
e.printStackTrace();
}