I am wanting to write from a text pane either into a .rtf file and then into a byte array or directly from the jtextpane to a byte array as long as I could still reconstruct it later into an .rtf file and still keep the formatting.
I am currently trying this error
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.io.File.<init>(File.java:222)
at mmsiserver.notesApp.updatePatientNotes(notesApp.java:2198)
on the following code. I don't think that using the getText() is correct but didn't see anything in the api on how to read from the jtextpane, I am still fairly new to java and sometimes misread or read over pieces of the api...here is my code.
try {
FileInputStream input = new FileInputStream(new File(notesPane.getText()));
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
byte[] data = null;
int count = 1;
int numBytesRead = 0;
while ((numBytesRead = input.read(buf)) != -1) {
output.write(buf, 0, numBytesRead);
count++;
}
data = output.toByteArray();
output.close();
input.close();
FileOutputStream out = new FileOutputStream(new File("c:/hi.rtf"));
out.write(data, 0, data.length);
out.close();
Thanks in advance