我編寫了一個程序,用於在我的PC中搜索具有給定擴展名的文件。現在我想添加一件事。我希望我的程序將這些文件複製到我個人電腦上的特定位置。這裏是我的代碼示例: -將搜索到的文件複製到特定位置
Finder(String pattern)
{
matcher = FileSystems.getDefault().getPathMatcher("glob:" + pattern);
}
// Compares the pattern against
// the file or directory name.
void find(Path file) {
Path name = file.getFileName();
if (name != null && matcher.matches(name)) {
System.out.println(file);
String s = new String(name.toString());
//System.out.println(s);
File f = new File(s);
//System.out.println(f.getAbsolutePath());
FileInputStream fileInputStream = null;
這裏的問題究竟是什麼? – Matthias
檢查[此線程](http://stackoverflow.com/questions/1146153/copying-files-from-one-directory-to-another-in-java) –
我想複製所有駐留在我的文本文件個人電腦,我的pendrive。我的程序正在成功搜索所有文本文件,現在我想複製這些..我怎麼能做到這一點? – Vicky