saving data to JTextPane

hi Forum,

I am trying to save data of JTextPane to File but i am not getting it.

can you help..?

outFile.close();*/

BufferedWriter out =new BufferedWriter(new OutputStreamWriter(

new FileOutputStream(fileName)));

String output= (chat.getTpAllMessages()).getText();

try{

System.out.println("Contained Text: " + (chat.getTpAllMessages()).getDocument().getText(0,chat.getTpAllMessages().getSelectionEnd()));

}catch (BadLocationException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

out.write(output,0,output.length());

out.close();

thanx

Message was edited by:

p_more_java

[1028 byte] By [p_more_javaa] at [2007-11-26 17:37:53]
# 1

u can write files like this , (I get my string as

File file = new File("Devices_Lst.txt ");

BufferedWriter out = new BufferedWriter(new FileWriter("Devices_Lst.txt", true));

String toWrite = TextField.getText();//+","+(""+unit)+","+jTextField16.getText()+"\n";

String toWrite1 = NameTextField.getText() ;

out.write(toWrite+" : "+toWrite1+"\n");

out.close();

u must remember to close the file writer.

instead of getting from text field, u get the input fron text area.

rameshsa at 2007-7-9 0:06:03 > top of Java-index,Desktop,Core GUI APIs...
# 2
All text components have a write(...) method.
camickra at 2007-7-9 0:06:03 > top of Java-index,Desktop,Core GUI APIs...