🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #28213

Prb: Clase URL, funci�n getContent

#28213
From: Diego Alonso
Date: Thu, 21 May 1998 00:00
41 lines
1848 bytes
Hola a todos!
Estoy intentando hacer una clase que dada una URL me de su c�digo HTML.
De momento s�lo estoy haciendo pruebas y he utilizado la funci�n
getContent de la clase URL. El problema es que no funciona casi nunca,
de hecho, s�lo he conseguido que funcione de mi ordenador al que tengo
al lado, pero cuando lo intento con alguna direcci�n exterior no va, se
queda colgado intentando hacer el getContent.
El c�digo es muy sencillo y os lo mando aqu�. Si alguien sabe lo que
hago mal o tiene alg�n ejemplo que haga eso... agradecer� cualquier
ayuda.

import java.io.*;
import java.net.*;
import java.applet.*;
import java.awt.*;

public class Http
{
  public static void main(String argv[])
  {
    try
    {
      Object obj;
      System.out.println("Nuevo URL...");
      URL miUrl = new URL("http://www.netaldea.es/index.html");
      System.out.println("Cogiendo contenido...");
      obj = miUrl.getContent();
      System.out.println("Contenido cogido...");
      BufferedInputStream bfIn = (BufferedInputStream)obj;
      DataInputStream stmIn = new DataInputStream(bfIn);
      String strRespuesta;
      while ( (strRespuesta = stmIn.readLine()).length()>0)
      {
        System.out.println(strRespuesta);
      }
    }
    catch (MalformedURLException e) {;}
    catch (IOException e){;}
  }
}
Technical Details
Message-ID: <35643E3B.D98990C2@netaldea.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: 1116f3,7023a65efd9a64c5,start
X-Google-Attributes: gid1116f3,public
From: Diego Alonso <diego@netaldea.es>
Subject: Prb: Clase URL, funci�n getContent
Date: 1998/05/21
Message-ID: <35643E3B.D98990C2@netaldea.es>
X-Deja-AN: 355248832
Content-Transfer-Encoding: 8bit
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Organization: Telefonica Transmision de Datos
Newsgroups: es.comp.lenguajes.java