Article View: es.comp.lenguajes.java
Article #29122Re: Acceso a un fichero
From: Chano G�mez
Date: Thu, 15 Jan 1998 00:00
Date: Thu, 15 Jan 1998 00:00
19 lines
1251 bytes
1251 bytes
> Hola quisiera que alguien me pudiera responder sobre la posibilidad
> de crear un APPLET, que acceda a un fichero y lo muestre por el browser.
>
> El fichero reside en la misma direcci�n donde se encuentra el
> applet, y el applet ha de abrirlo y mostar su contenido.
> No tengo mucha idea sobre este tema y necesitaria que alguien me
> hechara una mano.
Si sabes la URL donde se encuentra el fichero, solo tienes que hacer lo siguiente:
URL x= new URL(getCodeBase(),"nombreArchivo.txt");
InputStream is = x.openStream();
int c;
/* Mientras queden datos en el fichero, seguimos
leyendo. Se llega alfinal cuando read() devuelve -1 */
while((c=is.read())!=-1){
/* Aqu� har�s lo que quieras con el dato le�do */
}
Technical Details
Message-ID:
<34BE2A09.F17C70A3@ran.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<34BE01B8.16F4A668@vw-gedas.es>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: 1116f3,3789d81ff8b21453 X-Google-Attributes: gid1116f3,public From: "Chano G�mez" <chano@ran.es> Subject: Re: Acceso a un fichero Date: 1998/01/15 Message-ID: <34BE2A09.F17C70A3@ran.es> X-Deja-AN: 316257219 Content-Transfer-Encoding: 8bit References: <34BE01B8.16F4A668@vw-gedas.es> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Organization: Unisource Espana NEWS SERVER Newsgroups: es.comp.lenguajes.java