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");
}
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


0