實際上它只是製作一個text.txt文件的副本。我知道如何使用文件選擇器來選擇文件,但就我的知識而言,這確實如此。通過採取一看Basic I/O,這解釋了Input/OutputStreams
的基礎知識和Reader
S和Writer
s,這是用來從源中讀取數據/寫入字節如何在java中備份文件?
public BasicFile()
{
JFileChooser choose = new JFileChooser(".");
int status = choose.showOpenDialog(null);
try
{
if (status != JFileChooser.APPROVE_OPTION) throw new IOException();
f = choose.getSelectedFile();
if (!f.exists()) throw new FileNotFoundException();
}
catch(FileNotFoundException e)
{
display(1, e.toString(), "File not found ....");
}
catch(IOException e)
{
display(1, e.toString(), "Approve option was not selected");
}
}
你想知道如何複製文件? –
是的,我很樂意。 – user3236502