Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-12-2005, 09:40 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
how do i read a web page into a string?

i have a little web service i need to read with java.

url: http://mysite.com/myservice.php?name=foo

then the response just gives me either a url if that name exists, or a '0' if it doesn't.

i'm going to google it now and i'll post my answer if i find it sooner than i get a response. it makes for good site content.
__________________
Mike
sde is offline   Reply With Quote
Old 01-13-2005, 06:45 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
i forgot to post before i left work yesterday. here is the solution:
Code:
import java.io.*;
import java.net.*;

...

URL nameURLRequest = new URL("http://mysite.com/webservice.php?name=sde");
BufferedReader in = new BufferedReader(new InputStreamReader(
  nameURLRequest.openStream()));

String nameURLResponse;

if((nameURLResponse = in.readLine()) == null)
  nameURLResponse = "0";

in.close();
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for another program Androto Standard C, C++ 54 10-15-2004 07:21 AM
From C to Java HighterDK Java 11 07-13-2004 07:15 PM


All times are GMT -8. The time now is 11:03 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting