Re: Calling a shell function
From: CD Rasmussen (Constantine.Rasmussen_at_comcast.net)
Date: 10/05/03
- Next message: Phil...: "Re: Calling a shell function"
- Previous message: Allan Horwitz: "Simple Java Program to Draw a Rectangle on a Pane"
- In reply to: John Bowling: "Calling a shell function"
- Next in thread: Phil...: "Re: Calling a shell function"
- Reply: Phil...: "Re: Calling a shell function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 05 Oct 2003 14:41:02 -0400
If you are moving the files within the same filesystem, you can use the
Java File object to rename it like a Unix mv command.
See java.io.File.renameTo()
If you are going off the file system then you will have to do a copy and
delete. The copy would presumably be done using Buffered Streams. Be
careful not to ignore any exceptions since there could be an incomplete
copy and you'd then delete your source without a backup.
Constantine
John Bowling wrote:
> I'm creating a routine (not in a browser) to move multiple files on a daily
> basis to a backup directory. It can be done easily by call shell functions
> like 'mv file* newdir'.
> I can't find any reference in the Java tutorial about accessing or using the
> shell or system other than standard i/o. Does anyone have a clue on how to
> pass a command to the shell to execute a program?
>
> My other option is to write a shell script that calls a few minor Java
> routines (such as creating date based filenames) and does most things in the
> shell. I would need to pass multiple int and string variables both ways if
> I did that.
>
> Thanks, John.
>
>
- Next message: Phil...: "Re: Calling a shell function"
- Previous message: Allan Horwitz: "Simple Java Program to Draw a Rectangle on a Pane"
- In reply to: John Bowling: "Calling a shell function"
- Next in thread: Phil...: "Re: Calling a shell function"
- Reply: Phil...: "Re: Calling a shell function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|