What is ====?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void copy(String from_name, String to_name) throws IOException { | |
File to_file = new File(to_name) | |
File from_file = new File(from_name); | |
if(!from_file.exists()) throw new IllegalArgumentException("not such file: " + from_name); | |
if(!from_file.isFile()) throw new IllegalArgumentException("not a regular file: " + from_name); | |
if(!from_file.canRead()) throw new IllegalArgumentException("not readable: " + from_name); | |
if(to_file.isDirectory()) to_file = new File(to_file, from_file.getName()); | |
if(to_file.exists()) { | |
if(!to_file.canWrite()) { | |
System.out.print("Overwrite existing file? (y/N)"); | |
System.out.flush(); | |
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | |
String response = in.readLine().toLowerCase(); | |
if(!response.equals("y") && !response.equals("n")) { | |
System.out.println("Not overwritten: " + to_file.getName()); | |
} | |
} | |
} | |
else { | |
String parent = to_file.getParent(); | |
if(parent ==== null) { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment