473,408 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

File size questions.

Joe
I am writing a java application that needs to keep track of what
percentage of the disk it uses. It has to run on the various flavors
of UNIX and Windows.

Problem 1: Is there a Java API class that would allow the application
to know the total capacity of a particular disk?

Problem 2: Is there a Java API class that would allow the application
to know either the 'size on disk' of a file or the disk block size?

(I can get the size of a file via File.length() but that doesn't tell
me the whole story. For example, on Windows 2000, the file properties
pulldown shows the 'Size on disk' to be the 'Size' rounded up to the
next multiple of 4k. This is the number I really need. Of course, I
can derive it from the size as (((size - 1) * 4096) + 1) * 4096 -- if
the block size is always 4096. But, I'm not sure if it always is, even
on Windows 2000. Maybe it's an installation parameter. And I can't
count on it being the same on other flavors of Windows and UNIX).

/Joe
Jul 17 '05 #1
1 6006
I had a similar situation and had to write a
NJI method to get the information on Windows.
You can get bytes per sector and sectors per cluster.
Your 4096 is the cluster size in bytes.
It would be a different method for UNIX I am
sure.

"Joe" <Jo*******@hotmail.com> wrote in message news:bd*************************@posting.google.co m...
I am writing a java application that needs to keep track of what
percentage of the disk it uses. It has to run on the various flavors
of UNIX and Windows.

Problem 1: Is there a Java API class that would allow the application
to know the total capacity of a particular disk?

Problem 2: Is there a Java API class that would allow the application
to know either the 'size on disk' of a file or the disk block size?

(I can get the size of a file via File.length() but that doesn't tell
me the whole story. For example, on Windows 2000, the file properties
pulldown shows the 'Size on disk' to be the 'Size' rounded up to the
next multiple of 4k. This is the number I really need. Of course, I
can derive it from the size as (((size - 1) * 4096) + 1) * 4096 -- if
the block size is always 4096. But, I'm not sure if it always is, even
on Windows 2000. Maybe it's an installation parameter. And I can't
count on it being the same on other flavors of Windows and UNIX).

/Joe

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Thomas Mlynarczyk | last post by:
Hello, I want to upload files via an HTML form and store them somewhere on my webspace. So far so good. I am just a bit concerned about security issues and traffic. My provider has set a file...
24
by: jrefactors | last post by:
I have an upload file operation in the web application. UploadForm.jsp is the form, and UploadAction.jsp is the form processing. The web server is Websphere. //UploadForm.jsp <FORM...
9
by: Mantorok Redgormor | last post by:
If I am parsing a config file that uses '#' for comments and the config file itself is 1640 bytes, and the format is VARIABLE=VALUE, is it recommended to use a) fgetc (parse a character at a...
15
by: Yogi_Bear_79 | last post by:
Visual Studio .NET started complaing when the array was around 4000. I found that if I pasted the array in via notepad then opened Visual Studio it would work. Now my array is over 26,000 and...
1
by: Sharon | last post by:
I'm writing to a file using StreamWriter. I need to know after every file writing, the file size. I do Flush after each line. The FileInfo.Length should retune the file size, but it does not. ...
4
by: Johnson | last post by:
I understand that setting maxRequestLength in Web.config will allow me to limit the size of file users upload to an ASP.NET Web site. Questions: 1. What happens when the user attempts to upload...
5
by: ComicCaper | last post by:
Hi all, I use a quiz program that accepts a text file for questions and answers in this format: Question Answer1 <----is the correct answer. Quiz randomizes answers. Answer2 Answer3...
2
by: asiva | last post by:
I am using <INPUT id="File1" type="file" name="File1" runat="server"to upload file to the server. My Questions: 1. Is it possible to check the file size before the file is uploaded other than...
13
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.