Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Symbolic link files... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Symbolic link files..." Watch "Symbolic link files..." New topic
Author

Symbolic link files...

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Is it possible to create symbolic link files with Java 5?? If yes, how can I do this?

Also, is there a clean way in java 5 to copy a file from one directory to another directory?

TIA,
- Manish
[ May 23, 2006: Message edited by: Manish Hatwalne ]
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
To create a symbolic link you could use Runtime.exec(String command). As for copying a file, it could be done in many different ways. A simple option is to create a FileInputStream reading bytes from the source and writing them to the target FileOutputStream.

If you would like to simplify the whole process then maybe you would like to use Jakarta Commons IO, which provides a few method in the IOUtilities class that could make your life easier.

I hope this helps!
[ May 23, 2006: Message edited by: Edwin Dalorzo ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

Originally posted by Edwin Dalorzo:
To create a symbolic link you could use Runtime.exec(String command).


Which means, you just execute a system command (like "ln" on Unix) to do it. There is no method in the standard API to create a symbolic link. Note that symbolic links are a platform-specific feature (most Unix variants have it, but Windows doesn't). The standard API generally does not contain methods to do such platform-specific things.

Here's a fast an efficient way to copy a file:
Copying One File to Another using java.nio


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Jesper Young:
Note that symbolic links are a platform-specific feature (most Unix variants have it, but Windows doesn't)


Actually, Windows does have it. But they don't like to advertise it and it isn't very well integrated into Windows Explorer.

See junction.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
 
subject: Symbolic link files...