accessing web page in java

hi guys,

how can i access the web page in java?

i have tried the following way;;;

import java.io.*;

import javax.swing.*;

public class WebCrawler

{

public static void main(String args[])

{

JFrame frame = new JFrame();

JTextPane pane1=new JTextPane();

pane1.setEditable(false);

frame.add(pane1);

File test = new File("http://www.google.com");

try

{

pane1.setPage(test.toURL());

}

catch(Exception e)

{

e.printStackTrace();

}

frame.setVisible(true);

}

}

but its giving java.io.FileNotFoundException:

i think its because its searching the web page in local directory.

Any idea how to serach it over web

[768 byte] By [Yogesh.Turoc3a] at [2007-11-26 16:32:52]
# 1
File() class propose is access to objects in file system. You should use URLConnection, HttpURLConnection or even Socket instead.
Michael.Nazarov@sun.coma at 2007-7-8 22:57:28 > top of Java-index,Java Essentials,New To Java...
# 2

i have changed to following

////////////////////////////////////////////////////////////////////////////////////////////////////////////

URL test = new URL("http://www.google.com");

InetSocketAddress add = new InetSocketAddress("www-inpu.dienste.t-systems.com",8080);

Proxy prox = new Proxy(Proxy.Type.HTTP,add);

test.openConnection(prox);

test.openConnection();

pane1.setPage(test);

////////////////////////////////////////////////////////////////////////////////////////////////////////////

problem is solves to some extent but now giving different error

Yogesh.Turoc3a at 2007-7-8 22:57:28 > top of Java-index,Java Essentials,New To Java...
# 3
> problem is solves to some extent but now giving different errorWhy do you think we know about error you did not post?
Michael.Nazarov@sun.coma at 2007-7-8 22:57:28 > top of Java-index,Java Essentials,New To Java...
# 4
ya u are correct.... iam getting the following exceptionjava.net.NoRouteToHostException: No route to host: connect
Yogesh.Turoc3a at 2007-7-8 22:57:28 > top of Java-index,Java Essentials,New To Java...
# 5
Well you have no access to specified host. Check did you wrote correct host name. Did you have Internet connection also. :)
Michael.Nazarov@sun.coma at 2007-7-8 22:57:28 > top of Java-index,Java Essentials,New To Java...
# 6
You can try thisURL url=new URL("www.google.com");HttpURLConnection conn=(HttpURLConnection)url.openConnection();BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));And use " in" to read content from the web page.+Shagil
shagila at 2007-7-8 22:57:28 > top of Java-index,Java Essentials,New To Java...