File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Mac OS X > Copying JavaApplicationStub using Java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Mac OS X > Copying JavaApplicationStub using Java code " Watch "Mac OS X > Copying JavaApplicationStub using Java code " New topic
Author

Mac OS X > Copying JavaApplicationStub using Java code

Stig Halvor Mokksholm
Greenhorn

Joined: May 24, 2005
Posts: 2
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

Joined: May 24, 2005
Posts: 2
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();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mac OS X > Copying JavaApplicationStub using Java code
 
Similar Threads
File Extensions Mappings
Java SDK on Mac OSX
none of my java applications work with 1.5.0 on mac os 10.3.9
error message in terminal
Basic questions 2