Solved

URL Grabber

Posted on 2002-05-10
7
243 Views
Last Modified: 2010-03-31
hi,

i've the following code snippet to grab the return URL of another site:
--------------------------
urlRemote = new URL(strURL);              
in = new BufferedReader(
new InputStreamReader(urlRemote.openStream()));
while ( (strLine = in.readLine() ) != null )
{
     vecReturn.add(strLine);
}
in.close();

---------------------------
when i reach the above piece of codes, i was thrown the java.io.FileNotFoundException.

can someone tell me what could possibly be wrong?
thanks.
0
Comment
Question by:osiruz
  • 4
  • 3
7 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7000683
 Well it is obvious that it cannot find the file. Are you sure that the file you are trying to access exists?
0
 

Author Comment

by:osiruz
ID: 7000849
im not familiar with this url grabber thing..
i do not understand the above code fully,
can someone help ? If i were to grab a particular URL response from another site, how can this be achieve?
0
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
ID: 7000885
 The URL class represents exactly this: a url that points to a resource on the Internet. You cannot use it to read a response from a server but rather you can read files, directories, database queries etc. Maybe this will help you: http://java.sun.com/products/jdk/1.2/docs/api/java/net/URL.html

> If i were to grab a particular URL response from another site, how can this be achieve?

 What exactly do you mean by this? Do you want to connect to a server and read the response back (using Sockets) or you would like to do server-side processing (using Servlets/JSP)?

>urlRemote = new URL(strURL);

  You create a new URL object by passing a String representation of the url. String could be anything like: http://www.yahoo.com
             
>in = new BufferedReader(new InputStreamReader(urlRemote.openStream()));

  Once the url object is created you open a connection to the url and you get an InputStream for reading from this url.

>while ( (strLine = in.readLine() ) != null )
>{
>    vecReturn.add(strLine);
>}

  While there is data coming from this url then you append everything in a collection object (Vector).

>in.close();

  You close the stream fro reading from the url.

  Hope it helps.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:osiruz
ID: 7000931
im not familiar with this url grabber thing..
i do not understand the above code fully,
can someone help ? If i were to grab a particular URL response from another site, how can this be achieve?
0
 

Author Comment

by:osiruz
ID: 7000936
thanks..i'll need some time to digest that.
thanks again for the response.
0
 

Author Comment

by:osiruz
ID: 7065483
Thanks for the help.
0
 
LVL 35

Expert Comment

by:girionis
ID: 7065503
 Not at all. I am glad I helped. :-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now