Вход на сайт
Java
94
NEW 30.03.04 03:00
Подскажите, пложалуйста, как мне текст, набранный в JTextArea, при нажатии на кнопку "Speichern" (имеется) сохранить в файл.
Как привязать команду к кнопке - понятно, а вот как новый файл создать и туда текст cохранить - не понятно.
очень нужно....
Заранее благодарю
Как привязать команду к кнопке - понятно, а вот как новый файл создать и туда текст cохранить - не понятно.

очень нужно....
Заранее благодарю

NEW 30.03.04 04:11
в ответ Solna 30.03.04 03:00
Приветик!
посмотри здесь:
http://www.fh-wedel.de/~di/html/jdk12docs/api/java/io/package-summary.html
если непонятно будет или никто подробнее не напишет - пиши
Linux is like a Wigwam. No Windows! No Gates! And Apache inside.
посмотри здесь:
http://www.fh-wedel.de/~di/html/jdk12docs/api/java/io/package-summary.html
если непонятно будет или никто подробнее не напишет - пиши
Linux is like a Wigwam. No Windows! No Gates! And Apache inside.
Linux is like a Wigwam. No Windows! No Gates! And Apache inside.
NEW 30.03.04 13:43
в ответ pavel-hh 30.03.04 04:11
Spasibo, no tak ne poniatno(( Poprobuiu podrobnee:
Sozdala TextArea:
Container cp = getContentPane(,0);
JTextArea ta = new JTextArea(20, 30,0);
cp.add(new JScrollPane(ta),0);
Teper' nado Text, kotoryi ia tuda vpechataiu, perenesti na mesto ???:
String text = ???;
FileWriter fr;
try
{
fr = new FileWriter("Datei.txt",0);
fr.write(text,0);
fr.close(,0);
......
chtoby on u menia sohranilsia v File "Datei.txt"...
Sozdala TextArea:
Container cp = getContentPane(,0);
JTextArea ta = new JTextArea(20, 30,0);
cp.add(new JScrollPane(ta),0);
Teper' nado Text, kotoryi ia tuda vpechataiu, perenesti na mesto ???:
String text = ???;
FileWriter fr;
try
{
fr = new FileWriter("Datei.txt",0);
fr.write(text,0);
fr.close(,0);
......
chtoby on u menia sohranilsia v File "Datei.txt"...
NEW 30.03.04 14:14
в ответ Solna 30.03.04 13:43
getText
public String getText()
Returns the text contained in this TextComponent. If the underlying document is null, will give a NullPointerException.
String text = ta.getText(,0);
Не забудь проверку на null сделать.
Manche Hähne glauben, dass die Sonne ihretwegen aufgeht
NEW 30.03.04 17:11
BufferedReader in = new BufferedReader(new FileReader("Test.txt"),0);
String s1, s2 = new String(,0);
while( (s1 = in.readLine()) != null)
s2 += s1 + "\n";
in.close(,0);
Теперь содержимое файла находится в s2.
http://www.galileocomputing.de/openbook/javainsel3/
http://www.javabuch.de/
Попробуй эти книги
Manche Hähne glauben, dass die Sonne ihretwegen aufgeht
String s1, s2 = new String(,0);
while( (s1 = in.readLine()) != null)
s2 += s1 + "\n";
in.close(,0);
Теперь содержимое файла находится в s2.
http://www.galileocomputing.de/openbook/javainsel3/
http://www.javabuch.de/
Попробуй эти книги
Manche Hähne glauben, dass die Sonne ihretwegen aufgeht