Read from a URL : URL « Socket Network « VB.Net Tutorial






Imports System
Imports System.Net
Imports System.IO
Imports System.Environment

Module GetURL
    Sub Main()
        Dim sOutput As String
        Dim sURL As String = "http://www.java2s.com"
        Try
           Dim objNewRequest As WebRequest = HttpWebRequest.Create(sURL)
           Dim objResponse As WebResponse = objNewRequest.GetResponse
           Dim objStream As New StreamReader(objResponse.GetResponseStream())
           sOutput = objStream.ReadToEnd()

        Catch eUFE As UriFormatException
            sOutput = "Error in URL Format: [" & sURL & "]" & NewLine() & eUFE.Message
        Catch eWEB As WebException
            sOutput = "Error With Web Request: " & NewLine() & eWEB.Message
        Catch e As Exception
            sOutput = e.ToString
        Finally
            Console.Write(sOutput)
        End Try
    End Sub
End Module


     Java examples (example source code) Organized by topic 
        
    
    
    
    





22.1.URL
22.1.1.Read from a URL
22.1.2.Create StreamReader from URL