Article View: borland.public.jbuilder.java.language
Article #15106Re: Reading a http URL with simple text.
From: Scott Metzner
Date: Thu, 08 Jul 1999 00:00
Date: Thu, 08 Jul 1999 00:00
34 lines
1750 bytes
1750 bytes
try this Gary:
URL website =new URL(http://www.xxx.com");
URLConnection thiscon = website.openConnection();
BufferedReader in =
newBufferedReader(newInputStreamReader(thiscon.getInputStream()));
String time=in.readLine();
System.out.println(time);
Gary Klein wrote:
> I'm trying to read a string from an http webserver which gives the
> time.
> I'm supposed to be able to just read a string from this input after I
> make the connection. Here's what I do:
>
> String url = new(http:xxx.xx.xxx);
> URL webtime = new URL(url);
> connection = webtime.openConnection();
> connection.setDoInput(true);
> DataInputStream timestream = new
> DataInputStream(webtime.openStream());
> String UTCline = timestream.readLine();
> System.out.println(UTCline);
>
> The first 5 characters of this string are supposed to be a
> Julian date then a space followed by yy-mm-dd hh:mm:ss, ect.
> However the string starts with the yy-mm-dd. The Julian date is lost.
> I know that its there because It shows up when I just put the URL
> address in a browser. What am I doing wrong? Or is it them?
>
> Thanks for the help.
Technical Details
Message-ID:
<37850E7F.7AAC9D95@flash.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7llt3h$6ch1@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,414c6c46db24b753 X-Google-Attributes: gidf74b3,public From: Scott Metzner <smajic@flash.net> Subject: Re: Reading a http URL with simple text. Date: 1999/07/08 Message-ID: <37850E7F.7AAC9D95@flash.net> X-Deja-AN: 498825159 Content-Transfer-Encoding: 7bit References: <7llt3h$6ch1@forums.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Sandia National Laboratories Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language