次のスクリプトを実行してファイルを移動すると、java.io.FileNotFoundException: C:\Users\520\Desktop\Thing (Access is denied)
エラーが発生しました。これは、IDE を管理者権限で実行する必要があるということですか?
public static void moveFiles(){
InputStream inStream = null;
OutputStream outStream = null;
try{
File afile = new File("C:\\Users\\520\\Desktop\\hey.txt"); // Gotta specify initial path. Consider adding an input for this
File bfile = new File("C:\\Users\\520\\Desktop\\Thing");
inStream = new FileInputStream(afile);
outStream = new FileOutputStream(bfile);
byte[] buffer = new byte[1024];
int length; // copy the file content in bytes
while((length = inStream.read(buffer)) > 0){
outStream.write(buffer, 0, length);
}
inStream.close();
outStream.close();
afile.delete();
System.out.println("File was copied successfully!");
}catch(IOException e){
e.printStackTrace();
}
}