• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Symbolic link files...

 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic