Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mac OS X > Copying JavaApplicationStub using Java code

 
Stig Halvor Mokksholm
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This small problem has been posted on several forums, but still noone has come up with a good explanation, yet alone a SOLUTION...

I hope you are the one to give me the good answers I need

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...


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

Or a hint....?

Thanks, I would be VERY grateful
 
Stig Halvor Mokksholm
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, 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();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic