-
-
Save uncoded-ro/da6840fc9144c4309611cf4adb4ff189 to your computer and use it in GitHub Desktop.
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
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