-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUriTesting.java
More file actions
29 lines (25 loc) · 889 Bytes
/
UriTesting.java
File metadata and controls
29 lines (25 loc) · 889 Bytes
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
package array;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
* @author shivam.maharshi
*/
public class UriTesting {
public static void main(String[] args) {
long start = System.currentTimeMillis();
String file = "C:/Users/Sam/Downloads/elwiki-20151201-all-titles-in-ns0.txt";
List<String> urls = FileUtil.read(file);
List<String> out = new ArrayList<>(), fail = new ArrayList<>();
for (String url : urls)
try {
out.add(URLEncoder.encode(url, "UTF-8"));
} catch (UnsupportedEncodingException e) {
fail.add(url);
}
FileUtil.write(out, file + "encoded");
FileUtil.write(fail, file + "failed");
System.out.println("Encoded all URLs in: " + ((System.currentTimeMillis() - start) / 1000) + " seconds.");
}
}