Article View: es.comp.lenguajes.java
Article #27598Re: Una manera mejor de copiar ficheros
From: Juan Carlos
Date: Fri, 07 Aug 1998 00:00
Date: Fri, 07 Aug 1998 00:00
63 lines
2126 bytes
2126 bytes
Joe, tio. Te pillo hasta en las news, y eso que hace tiempo que no las
leo.
Ahora las necesito y a ver si me echa alguien un cable. Es sobre una
idiotez de sun y sus API�s.
Un saludete
mailto:jcbueno@yahoo.com
Aqu� tienes un m�todo que te puede ayudar algo que creo que te puede
ayudar.
Adem�s te pongo un ejemplo de como utilizarlo...
-------------- begin metodo
protected void copyInToOut (BufferedInputStream in, BufferedOutputStream
out) throws IOException
{
int length;
byte data[] = new byte[8192];
while ( (length=in.read(data)) != -1 )
{
out.write (data, 0, length);
}
}
------------ end metodo
------------ begin ejemplo
BufferedInputStream inputStream = new BufferedInputStream (new
FileInputStream (file));
copyInToOut (inputStream, new BufferedOutputStream (
/*getOutputStream() como por ejemplo un OutputStream buffered con otro
file para volcado */));
----------- end ejemplo
Juan Pedro Barbancho Manch�n wrote:
> Hola,
> Alguien conoce un algoritmo mejor para copiar un fichero
> Los input and ouptstream derivan de Buffered input y outputstream
> El codigo:
>
> public void copy(InputStream in, OutputStream out) throws IOException
> {
> int i =0;
> for (int b = in.read();b != -1; b=in.read())
> {
> out.write(b);
> i++;
> if(i==512){
> setChanged();
> notifyObservers(new Integer( 512));
> i = 0;
> }
> }
> setChanged();
> notifyObservers(new Integer( i));
> }
>
> Gracias
> JuanP
Technical Details
Message-ID:
<35CAE24B.89E78F33@santandersupernet.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35CACB3E.6C3D834B@uco.es>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1116f3,1a8c4fe379e5732a X-Google-Attributes: gid1116f3,public From: Juan Carlos <BUENOV@santandersupernet.com> Subject: Re: Una manera mejor de copiar ficheros Date: 1998/08/07 Message-ID: <35CAE24B.89E78F33@santandersupernet.com> X-Deja-AN: 378812946 Content-Transfer-Encoding: 8bit References: <35CACB3E.6C3D834B@uco.es> To: "Juan Pedro Barbancho Manch�n" <ct2bamaj@uco.es> Content-Type: text/plain; charset=iso-8859-1 Organization: Telefonica Transmision de Datos Mime-Version: 1.0 Newsgroups: es.comp.lenguajes.java