Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

localhost URL

  Asked By: Bastet    Date: Jan 19    Category: Java    Views: 652

I am trying to get my intranet web page in my java application, how do i get to
do it? will java.net.url help?



2 Answers Found

Answer #1    Answered By: Troy Kelley     Answered On: Jan 19

try this

StringBuffer sb = new StringBuffer()
HttpURLConnection httpurlconnection = (HttpURLConnection)( new URL( "ur intranet
address" ) ).openConnection();
if( httpurlconnection.getResponseCode() == httpurlconnection.HTTP_OK
InputStream is = httpurlconnection.getInputStream();
int iRead=0;
while( ( iRead = is.read() ) != -1 )
sbPage.append( ( char ) iRead );

I am trying to get my intranet web  page in my java  application, how do i get to
do it? will java.net.url help?

Answer #2    Answered By: Gorkem Yilmaz     Answered On: Jan 19

This code will help  u to read the html content of any web  page, but your
application must convert the acquired html to application  presentation, or u
may filter the html tags to get the data u need then display it as u want:

String line;
BufferedReader in;
URL u = new URL("http://"+host+"/"+file);
In = new BufferedReader(new InputStreamReader(u.openStream()));
while ((line = in.readLine() != null)
} } catch (MalformedURLException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();} }

Didn't find what you were looking for? Find more on localhost URL Or get search suggestion and latest updates.