紧急求救:怎样把输入框里的内容自动保存成文本文档,比如保存成bb.txt,在这里bb.txt本身不存在是自动生成的.
紧急求救:怎样把输入框里的内容自动保存成文本文档,比如保存成bb.txt,在这里bb.txt本身不存在是自动生成的.
------解决方案--------------------File fileName = new File( "D: "+File.separator+ "bb.txt ");
BufferedWriter br = null;
try
{
if (!fileName.exists())
{
if (fileName.createNewFile())
{
br = new BufferedWriter(new FileWriter(fileName));
}
}
else
{
br = new BufferedWriter(new FileWriter(fileName));
}
br.write( "aaaa ");
br.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}