Java - Lectura ficheros binarios

 
Vista:

Lectura ficheros binarios

Publicado por Jorge (6 intervenciones) el 25/06/2001 09:52:05
En realidad el problema es que consigo que me lea de un fichero pero pierde los 8K primeros tanto en archivos de texto como binarios. Este es el trozo de codigo:

BufferedInputStream bufferin = new BufferedInputStream(urlc.getInputStream());
DataInputStream input = new DataInputStream(bufferin);

boolean fin = false;
byte nuevoByte = 0;

try
{
nuevoByte = input.readByte();
}
catch(EOFException e1)
{
fin = true;
}

File fichero = new File(nombredir,nombrefichero);
FileOutputStream fileoutfich = new FileOutputStream(fichero);
BufferedOutputStream bufferfich = new BufferedOutputStream(fileoutfich);
DataOutputStream salidafichero = new DataOutputStream(bufferfich);

while (!fin)
{
salidafichero.writeByte(nuevoByte);
try
{
nuevoByte = input.readByte();
}
catch(EOFException e)
{
fin = true;
System.out.println("Alcanzado el fin de fichero");
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder