•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,397 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,285 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2616 | Replies: 7
![]() |
•
•
Join Date: Sep 2006
Posts: 65
Reputation:
Rep Power: 0
Solved Threads: 0
hi im janaka priyadarshana,
I want to write a program to access a given URL. dont need to show it on a browser. only want to get the html tags and write it on a text file.
serch on internet for this purpos, but unable to find any idea.
please if you can help me, give me an idea to do this using java
thank you.
I want to write a program to access a given URL. dont need to show it on a browser. only want to get the html tags and write it on a text file.
serch on internet for this purpos, but unable to find any idea.
please if you can help me, give me an idea to do this using java
thank you.
•
•
Join Date: Jul 2006
Location: Glenelg, Adelaide
Posts: 229
Reputation:
Rep Power: 3
Solved Threads: 11
See Above link. The class you want is probably HttpUrlConnection.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jul 2006
Location: Glenelg, Adelaide
Posts: 229
Reputation:
Rep Power: 3
Solved Threads: 11
By the way, I noticed you didn't even bother to google Yeah you really "...serch on internet for this purpos, but unable to find any idea..."
And use a spell checker, even if only to prevent putting off people who could help you.
•
•
•
•
java access a url
And use a spell checker, even if only to prevent putting off people who could help you.
Last edited by DavidRyan : Sep 21st, 2006 at 3:23 am.
Please anyone, correct me if I am wrong. It is the best way for me to learn.
•
•
Join Date: Sep 2006
Posts: 65
Reputation:
Rep Power: 0
Solved Threads: 0
janaka priyadarshana
i tried to execute the following program that was got from sun java tutorials. but it gave some execeptios as follow. unable to find why.
please help me to do that
import java.net.*;
import java.io.*;
public class MyURLConnection {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.google.com/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
the given exception is as follw.
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.http://www.http.HttpClient.openServe...lient.java:365)
at sun.net.http://www.http.HttpClient.openServe...lient.java:477)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
at sun.net.www.http.HttpClient.New(HttpClient.java:287)
at sun.net.www.http.HttpClient.New(HttpClient.java:299)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:792)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:744)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:669)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:913)
at MyURLConnection.main(MyURLConnection.java:9)
i tried to execute the following program that was got from sun java tutorials. but it gave some execeptios as follow. unable to find why.
please help me to do that
import java.net.*;
import java.io.*;
public class MyURLConnection {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.google.com/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
the given exception is as follw.
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.http://www.http.HttpClient.openServe...lient.java:365)
at sun.net.http://www.http.HttpClient.openServe...lient.java:477)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
at sun.net.www.http.HttpClient.New(HttpClient.java:287)
at sun.net.www.http.HttpClient.New(HttpClient.java:299)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:792)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:744)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:669)
at sun.net.http://www.protocol.http.HttpURLConn...ction.java:913)
at MyURLConnection.main(MyURLConnection.java:9)
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 199
•
•
Join Date: Jul 2006
Location: Glenelg, Adelaide
Posts: 229
Reputation:
Rep Power: 3
Solved Threads: 11
•
•
Join Date: Aug 2004
Location: North Carolina
Posts: 27
Reputation:
Rep Power: 5
Solved Threads: 2
There is nothing wrong with this code. Read the first line of the exception:
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
Your connection timed out. That's all.
http://www.ecst.csuchico.edu/~tlopez...Exception.html
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
Your connection timed out. That's all.
http://www.ecst.csuchico.edu/~tlopez...Exception.html
Last edited by Banderson : Sep 24th, 2006 at 7:37 pm. Reason: Added URL
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Creating first GUI Java Program (Java)
- put the Dos 's command into java program? (Java)
- my first java program (Java)
- JAVA program help (Student/Grades) (Java)
- Help with a java program home work assignment (Java)
Other Threads in the Java Forum
- Previous Thread: Converting lowercase type to uppercase (new programmer)
- Next Thread: Error configuring application listener



Linear Mode