D
Derek
Hello:
I want copy files from a directory to other (both in the same machine). This
copy process is successful: first it read the source file and then write the
data to the new file.
The problem is the following. One of the files that I copy is .php
("site.ini.append.php") and this is used for other application that work
with this php file. But, the application fault when use this file. This file
is about configuration.
But, If I edit this file (site.ini.append.php) with an editor, i.e. Windows
notebook, and I click on "File->save", the application, that use this file,
work fine now.
What is the problem?. I don´t have idea.
The code to read and write the file is the following:
/**** Read file *****/
public static byte[] LeerFichero(String file) {
byte[] datos = null;
try {
BufferedInputStream entrada = new BufferedInputStream(new
FileInputStream(file));
datos = new byte[entrada.available()];
entrada.read(datos);
entrada.close();
}
catch(java.io.FileNotFoundException fnfirma) {
System.out.println("Archivo no encontrado: " + fnfirma);}
catch(java.io.IOException ioex) {}
return datos;
}
/***** Write file ******/
public static void EscribirFichero(String file, byte[] datos) {
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(file);
} catch (FileNotFoundException e) {e.printStackTrace();}
try {
outStream.write(datos);
} catch (IOException e1) {e1.printStackTrace();}
try {
outStream.close();
} catch (IOException e2) {e2.printStackTrace();}
}
Thanks.
I want copy files from a directory to other (both in the same machine). This
copy process is successful: first it read the source file and then write the
data to the new file.
The problem is the following. One of the files that I copy is .php
("site.ini.append.php") and this is used for other application that work
with this php file. But, the application fault when use this file. This file
is about configuration.
But, If I edit this file (site.ini.append.php) with an editor, i.e. Windows
notebook, and I click on "File->save", the application, that use this file,
work fine now.
What is the problem?. I don´t have idea.
The code to read and write the file is the following:
/**** Read file *****/
public static byte[] LeerFichero(String file) {
byte[] datos = null;
try {
BufferedInputStream entrada = new BufferedInputStream(new
FileInputStream(file));
datos = new byte[entrada.available()];
entrada.read(datos);
entrada.close();
}
catch(java.io.FileNotFoundException fnfirma) {
System.out.println("Archivo no encontrado: " + fnfirma);}
catch(java.io.IOException ioex) {}
return datos;
}
/***** Write file ******/
public static void EscribirFichero(String file, byte[] datos) {
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(file);
} catch (FileNotFoundException e) {e.printStackTrace();}
try {
outStream.write(datos);
} catch (IOException e1) {e1.printStackTrace();}
try {
outStream.close();
} catch (IOException e2) {e2.printStackTrace();}
}
Thanks.