-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoad.java
More file actions
29 lines (25 loc) · 1.1 KB
/
Load.java
File metadata and controls
29 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
public class Load {
public static void Load() throws java.net.URISyntaxException, java.net.MalformedURLException, java.io.IOException {
FileInputStream roms = new FileInputStream(new File("Roms.txt"));
Scanner romsScanner = new Scanner(roms);
while (romsScanner.hasNextLine()) {
String file = romsScanner.nextLine();
URL url = new URI(file).toURL();
InputStream in = url.openStream();
String decoded = java.net.URLDecoder.decode(file, StandardCharsets.UTF_8.displayName());
Files.deleteIfExists(Paths.get(decoded.substring(decoded.lastIndexOf("/") + 1)));
Path path = Files.createFile(Paths.get(decoded.substring(decoded.lastIndexOf("/") + 1)));
Files.copy(in, path, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
}
}
}