Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to get the owner and time information of a file in the UNIX?

Reply
Thread Tools

how to get the owner and time information of a file in the UNIX?

 
 
jojo
Guest
Posts: n/a
 
      09-08-2005
hi,

I wanna get the detailed file information , such as owner, time in the
UNIX system. how to implement it in Java? thanks

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-09-2005
On 8 Sep 2005 16:31:57 -0700, "jojo" <(E-Mail Removed)> wrote or
quoted :

>I wanna get the detailed file information , such as owner, time in the
>UNIX system. how to implement it in Java? thanks


Time you get with File.last Modified. There are a few other bits of
info you can get. See http://mindprod.com/jgloss/file.html

For the rest, you will need to write some JNI. Basically you write a
program in C/C++ to get what you want and pass it back to Java.

See http://mindprod.com/jgloss/jni.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
 
Luke
Guest
Posts: n/a
 
      09-09-2005
In article <(E-Mail Removed)>,
Roedy Green <(E-Mail Removed)> wrote:

> On 8 Sep 2005 16:31:57 -0700, "jojo" <(E-Mail Removed)> wrote or
> quoted :
>
> >I wanna get the detailed file information , such as owner, time in the
> >UNIX system. how to implement it in Java? thanks

>
> Time you get with File.last Modified. There are a few other bits of
> info you can get. See http://mindprod.com/jgloss/file.html
>
> For the rest, you will need to write some JNI. Basically you write a
> program in C/C++ to get what you want and pass it back to Java.
>
> See http://mindprod.com/jgloss/jni.html


If you didn't want to resort to JNI and C/C++ code, you could probably
use Runtime.exec() to issue the unix ls command, then capture and parse
the output. This isn't going to be very portable, but then neither is
JNI.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-09-2005
On Thu, 08 Sep 2005 20:46:07 -0500, Luke <(E-Mail Removed)> wrote or
quoted :

>If you didn't want to resort to JNI and C/C++ code, you could probably
>use Runtime.exec() to issue the unix ls command, then capture and parse
>the output. This isn't going to be very portable, but then neither is
>JNI.


At least with JNI and JAWS it is possible to implement the same native
class on various platforms. JAWS automatically selects the correct
version. Your code stays constant. With the exec method, you need to
cook something up different for each platform in the application.
Further there is a big overhead for an exec that is often intolerable
for something you want to call thousands of times.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Hemal Pandya
Guest
Posts: n/a
 
      09-09-2005

jojo wrote:
> hi,
>
> I wanna get the detailed file information , such as owner, time in the
> UNIX system. how to implement it in Java? thanks


http://pandonia.canberra.edu.au/java/posix/
http://www.basepath.com/aup/jtux/

There might be more. Search for java+posix

 
Reply With Quote
 
Luke
Guest
Posts: n/a
 
      09-10-2005
In article <(E-Mail Removed)>,
Roedy Green <(E-Mail Removed)> wrote:

> On Thu, 08 Sep 2005 20:46:07 -0500, Luke <(E-Mail Removed)> wrote or
> quoted :
>
> >If you didn't want to resort to JNI and C/C++ code, you could probably
> >use Runtime.exec() to issue the unix ls command, then capture and parse
> >the output. This isn't going to be very portable, but then neither is
> >JNI.

>
> At least with JNI and JAWS it is possible to implement the same native
> class on various platforms. JAWS automatically selects the correct
> version. Your code stays constant. With the exec method, you need to
> cook something up different for each platform in the application.
> Further there is a big overhead for an exec that is often intolerable
> for something you want to call thousands of times.


I'm not familiar with JAWS, but it sounds like you're saying that with
JNI/JAWS the application stays constant and you reimplement the c/c++
code on each platform, where with the exec method you'd need to
reimplement the application class on each platform.

One way to minimize overhead with the exec method is to keep the process
running instead of starting up a new process for each call. The process
might initially start a unix shell (like bash) and then each call would
simply pass a unix command to the process and parse the output.
 
Reply With Quote
 
Gordon Beaton
Guest
Posts: n/a
 
      09-10-2005
On Sat, 10 Sep 2005 03:31:59 -0500, Luke wrote:
> One way to minimize overhead with the exec method is to keep the
> process running instead of starting up a new process for each call.
> The process might initially start a unix shell (like bash) and then
> each call would simply pass a unix command to the process and parse
> the output.


How is using an additional process to create a new process for each
command on your behalf (and keeping it around even when it's not
needed), using less resources than just creating each new process
yourself?

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
Joan
Guest
Posts: n/a
 
      09-10-2005

"jojo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> hi,
>
> I wanna get the detailed file information , such as owner, time
> in the
> UNIX system. how to implement it in Java? thanks


Use run and the command "ls -l <filename>"

 
Reply With Quote
 
Luke
Guest
Posts: n/a
 
      09-10-2005
In article <43229f87$(E-Mail Removed)>, Gordon Beaton <(E-Mail Removed)>
wrote:

> On Sat, 10 Sep 2005 03:31:59 -0500, Luke wrote:
> > One way to minimize overhead with the exec method is to keep the
> > process running instead of starting up a new process for each call.
> > The process might initially start a unix shell (like bash) and then
> > each call would simply pass a unix command to the process and parse
> > the output.

>
> How is using an additional process to create a new process for each
> command on your behalf (and keeping it around even when it's not
> needed), using less resources than just creating each new process
> yourself?
>
> /gordon


Suppose I want to execute the 'ls' command 100 times. I could create
100 processes to do this:

for (int i = 0; i < 100; i++)
{
create a new process and issue the 'ls' command
}

Or I could create one long running process,

Process P = create a new process

for (int i = 0; i < 100; i++)
{
use P to issue the 'ls' command
}

In the first example I've created 100 processes, while in the second
I've only created one process. Doesn't that reduce overhead
significantly?
 
Reply With Quote
 
Chris Head
Guest
Posts: n/a
 
      09-11-2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Luke wrote:
[snip]
> Suppose I want to execute the 'ls' command 100 times. I could create
> 100 processes to do this:
>
> for (int i = 0; i < 100; i++)
> {
> create a new process and issue the 'ls' command
> }
>
> Or I could create one long running process,
>
> Process P = create a new process
>
> for (int i = 0; i < 100; i++)
> {
> use P to issue the 'ls' command
> }
>
> In the first example I've created 100 processes, while in the second
> I've only created one process. Doesn't that reduce overhead
> significantly?


Greetings,
No. Overhead is NOT reduced because, on Linux and I think most other
UNIX systems, "ls" is a program. Every time you type "ls" at a command
prompt, you are starting another process. The only difference between
your examples is WHO is creating the new process, NOT whether or not a
new process is being created.

$ which ls
/bin/ls

Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDI8jQ6ZGQ8LKA8nwRAghBAJsGFLeuBh2nYvVo1vwugI r053AcpwCgw9tQ
GMO4tMT38HqBuqcMOKVcHnI=
=vX1H
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get file owner in Windows Thibault Ketterer Python 0 07-23-2007 07:55 AM
Windows: get owner and group of a file kai rosenthal Python 6 12-07-2006 11:31 PM
Interesting information about Pricewatch.Com and its owner investigations05@aol.com Digital Photography 11 09-22-2005 02:23 AM
page owner information in footer of website Whitney Javascript 1 08-03-2004 12:46 AM
Seek owner of HP omnibook 600ct computer for Information ! FØDUK Computer Information 0 11-04-2003 04:44 PM



Advertisments