public String updateTasks(String oldBean, String catName,String taskname1)
{
File inputFile = new File(catName+".todo");
File tempFile = new File("myTempFile.todo2");
BufferedReader reader1 = null ;//
BufferedWriter writer1 = null;//
String lineToEdit = taskname1;
String currentLine;
try {
writer1=new BufferedWriter(new FileWriter(tempFile));
reader1=new BufferedReader(new FileReader(inputFile));
}
catch (IOException e)
{
e.printStackTrace();
}
try {
while((currentLine = reader1.readLine()) != null) {
String[] sa = currentLine.split(":");
if(sa[0].equals(lineToEdit))
{
writer1.write(oldBean+ System.getProperty("line.separator"));
//continue;
}
writer1.write(currentLine + System.getProperty("line.separator"));//this //is supposed to write to a file
return Constants.SUCCESS;
}
} catch (IOException e) {
e.printStackTrace();
System.out.println("error occurred....");
}
return null;
}
этот метод должен писать в myTempFile.todo1, но не будет писать
что-нибудь.
файл создан хорошо, но ничего не пишет.
поскольку write ничего не возвращает, проверять это невозможно.