Re: Calling a shell function

From: CD Rasmussen (Constantine.Rasmussen_at_comcast.net)
Date: 10/05/03


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



Relevant Pages

  • Re: My shell cant find Java
    ... I downloaded java with netbeans from Sun ... >> Each time I type java I get an unknown command error. ... how you set environment variable depends on what shell you're using. ...
    (comp.lang.java.help)
  • Re: Piping output of one command into builtin "read" command
    ... #Java is revision 1.4 ... environment variables are, like arguments, strings passed from ... command to command. ... I thing you're confusing it with shell ...
    (comp.unix.shell)
  • Re: [SLE] PID file for java process?
    ... "java -jar jarfile.jar" launches the program, ... You can unpack a JAR file using either the "jar" command or the zip, ... interactively or via a shell script. ...
    (SuSE)
  • Re: Changing the shell through a C program
    ... use forkand execto execute the Java program directly. ... you want to use some other shell, ... works only if command is a single word ...
    (comp.unix.programmer)
  • Why newbies dont RTFM...
    ... Even though I've used Linux before, I've never had to do any ... BASH BUILTIN COMMANDS ... last command exited within ... unless the shell is not exeâ ...
    (comp.os.linux.misc)