Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

shmokk

macrumors newbie
Original poster
May 19, 2005
1
0
I have a java application that copies files from one folder to another.

This works fine on Windows, but on Mac OS X a Unix executable file like JavaApplicationStub appearently does not like to be copied using Java...

I have tested the application trying to duplicate a whole MyApplication.app package.

I realize that the file system is somewhat different on Mac than Windows, but I have a hard time accepting that java should not be able to copy a unix executable file from one folder to another without damaging the file...?

The copied file has the same size, but the file info does not say "Unix executable file" but "Document".

If I double-click it, it is opened using Terminal, but all it says is "Welcome to Darwin"

If I double-click the original file, (in the original package) the embedded java application is launched...

I used chmod on the file, and added execute permission. This only resulted in a change in file type description, it was changed from "Document" to "Terminal document." Still nothing more than "Welcome to Darwin" when double-clicking it.

Can anyone give me a piece of Java code that successfully copies (duplicates) a Unix executable file?

Or a hint....?

The following is basically the code I have used:
byte[] buf;
BufferedInputStream bis;
BufferedOutputStream bos;
int bytesRead;
int fileSize;

fileSize = (int)sourceFile.length();
buf = new byte[512];
bis = new BufferedInputStream(new FileInputStream(sourceFile));
bos = new BufferedOutputStream(new FileOutputStream(destFile));
while ((bytesRead = bis.read(buf)) > -1) {
bos.write(buf, 0, bytesRead);
}
bis.close();
bos.close();


Thanks, I would be VERY grateful if you could help me out :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.