Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created June 13, 2022 13:46
Show Gist options
  • Save uncoded-ro/da6840fc9144c4309611cf4adb4ff189 to your computer and use it in GitHub Desktop.
Save uncoded-ro/da6840fc9144c4309611cf4adb4ff189 to your computer and use it in GitHub Desktop.
package ro.virtualcampus.read;
import java.io.*;
import java.net.*;
public class ReadFromURL {
public static void main(String args[]) {
BufferedReader fin = null;
try {
URL address = new URL("https://virtualcampus.ro");
fin = new BufferedReader(new InputStreamReader(address.openStream()));
String buffer;
while ((buffer = fin.readLine()) != null) {
System.out.println(buffer);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if(fin != null) fin.close();
}
catch(IOException e) {
e.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment