Scanner sc = new Scanner(System.in);
System.out.println("请输入一个文件路径");
String line = sc.nextLine();
File file = new File(line);
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(file.getName());
int len;
byte[] arr = new byte[8192];
while((len = fis.read(arr)) != -1) {
fos.write(arr,0,len);
}
fis.close();
fos.close(); |
|