The Artima Developer Community
Sponsored Link

Java Answers Forum
FileNotFound Exception on url.openStream()

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Balaji

Posts: 1
Nickname: bala
Registered: Feb, 2002

FileNotFound Exception on url.openStream() Posted: Feb 26, 2002 9:43 PM
Reply to this message Reply
Advertisement
I get File not found when i request for a page from google.
But it works fine with other search engines.
Any ideas as to why?

The error:

$ java x java
Exception in thread "main" java.io.FileNotFoundException: http://www.google.com/search?q=java&btnG=Google-Suche&hl=en&meta=
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.ja va:545)
at java.net.URL.openStream(URL.java:798)
at x.main(x.java:10)

---------------------------------
The code:

import java.net.*;
import java.io.*;

public class x {

/**Main-Method*/
public static void main(String[] args) throws Exception {
String frage = args[0];
URL google = new URL("http://www.google.com/search?q=" + frage + "&btnG=Google-Suche&hl=en&meta=");
BufferedReader in = new BufferedReader(
new InputStreamReader(
google.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}

Topic: download servlet Previous Topic   Next Topic Topic: creating xml

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use