понедельник, 2 мая 2011 г.

Как дописывать текст в конец файла

Вызываем конструктор FileWriter со вторым параметром true.
Пример кода под катом:

File file = new File(path_file);
try {
    FileWriter wfile = new FileWriter(file, true);
    wfile.append(word.getText() + "\t" + translate.getText() + "\n");
    wfile.flush();
    wfile.close();
    word.setText("");
    translate.setText("");
} catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

Комментариев нет:

Отправить комментарий