🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
2 messages
2 total messages Started by Chris Thu, 17 Mar 2005 07:02
File.lengh() return 0 while the file's length > 0 on Linux
#61
Author: Chris
Date: Thu, 17 Mar 2005 07:02
17 lines
1401 bytes
Howdy, 

When using File.length to get the size of a file on linux, it returns 0;
but I am sure the file has contents, Could someone give me a hint?

Thanks in advance .

//test.java
import java.io.*;
public class test
{
       public static void main(String args[])
       {
               File file = new File("/proc/mdstat");
               System.out.println("file.length(): " + file.length());
       }
}
Re: File.lengh() return 0 while the file's length > 0 on Linux
#62
Author: Kevin Dean [TeamB]
Date: Thu, 17 Mar 2005 16:28
39 lines
2297 bytes
Chris wrote:

> When using File.length to get the size of a file on linux, it returns
> 0; but I am sure the file has contents, Could someone give me a hint?
> 
> Thanks in advance .
> 
> //test.java
> import java.io.*;
> public class test
> {
>        public static void main(String args[])
>        {
>                File file = new File("/proc/mdstat");
>                System.out.println("file.length(): " + file.length());
>        }
> }

The /proc filesystem is a special file system that maintains process
state.  The contents don't exist on disk but rather in memory, and the
contents are highly dynamic.  Because you're not opening a real file
per se, there's no easy way to determine the length, so Java returns 0.

Details on /proc can be found here:

http://www.freeos.com/articles/2879/

-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads