[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-java
Subject:    Re: UNIX/Linux commands w/i Java
From:       Sean OwensSean Owens <owens+ () cs ! cmu ! edu>
Date:       2001-06-14 16:20:27
[Download RAW message or body]

Priestley, Andy writes:
 > Hello Everyone!
 > 
 > I'm new to this mailing list and am looking quite forward to conversing w/ you all. 
 > 
 > I'm attempting to put UNIX commands w/i in my Java code. A simple
 > example of this would be to change directories on the UNIX box and
 > look for files w/ a given extension. I'm having a difficult time
 > locating documentation on how to do this, and more complex forms of
 > the same idea. Do any of you have any experience in this area or
 > can point me to some documentation our online source code that does
 > similar tasks. I'd be ver grateful. Thanks for your help.

For the kind of thing you're talking about, you should use the
appropriate java classes.  Look at java.io.File.  Also, dig around on
search engines for "java reading directories".  I quickly found this;

http://www.artima.com/java/answers/Jul2000/messages/73.html

which may help.

Now, if your example was merely a bad example, and you still have a
need to run external programs on linux, then you should check out the
'exec' method on class java.lang.Runtime.  It is a bit tricky to use
properly, but there is an excellent tutorial here;

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html

Good luck.


Sean

-- 
Sean R. Owens
owens+@cs.cmu.edu
412-268-3194 (office number)


----------------------------------------------------------------------
To UNSUBSCRIBE, email to java-linux-request@java.blackdown.org
with a subject of "unsubscribe". Trouble? Contact karl@blackdown.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic