public static int copyFiles(String orgFile, String newFile) throws AccessControlException
{
String fromFile = orgFile;//+path
//"C://~//Documents//NetBeansProjects//ProjectJ2MEWebsite//build//web//resources//Creek.jpg";
String toFile = newFile;//path;
System.out.println("copy image: "+fromFile+" to "+toFile);
// Create files from canonical file names.
File file1 = new File(fromFile);
File file2 = new File(toFile);
// Copy file(s).
try
{
// Define and initialize FileReader(s).
FileImageInputStream inImageFile = new FileImageInputStream(file1);
FileImageOutputStream outImageFile = new FileImageOutputStream(file2);
// Read character-by-character
int c =0;
while ((c = inImageFile.read()) != -1) {
outImageFile.write(c); }
// Close Stream(s).
inImageFile.close();
outImageFile.close();
//throws all the stream datas
//System.gc();
} catch (IOException e) {
System.out.print("copy file error: "+e.toString());
return 0;
}
return 1;
}
it is able to copy all the files( i think), i have tried image, and jar file. it works well.