convert url to file in java code example
Example: java download file from url to string
public static String URLReader(URL url) throws IOException {
StringBuilder sb = new StringBuilder();
String line;
InputStream in = url.openStream();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
while ((line = reader.readLine()) != null) {
sb.append(line).append(System.lineSeparator());
}
} finally {
in.close();
}
return sb.toString();
}