473,699 Members | 2,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6029
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*******@hotm ail.com> wrote in message news:bd******** *************** **@posting.goog le.com...
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
6428
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 size limit of 20MB in php.ini. My questions are: 1) If some evil web terrorist tries to upload a file which is larger than the maximum allowed by the setting in php.ini - will the transfer be cancelled by the server when the limit is reached so...
24
2746
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 NAME="InputForm" ACTION="UploadAction.jsp" METHOD="POST" enctype=multipart/form-data> <input type="file" name="fileName"> //etc ...
9
23599
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 time) b) fgets (read in blocks of whatever size) c) fread (get the size of the file and fread the entire thing into memory) and when would it be appropriate to use either a, b, or c?
15
1739
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 Visual Studio just doesn't like it. Everytime I open the prokect I get the following error: "An Error occurred which the C# comipler is unable to report due to low memory or possible heap corruption. It is recommended that you save all your files,...
1
14467
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. Here is what I'm doing: StreamWriter myFile = File.AppendText(fileName); myFile .Flush();
4
1606
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 a file that is larger than the max that I specify via maxRequestLength? Is there some exception I can handle and then have some nice way to tell the user what happened? 2. Even better - is there any reasonably easy way to determine the file size...
5
1807
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 Answer4
2
1820
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 using Scripting.FileSystemObject ? 2. If answer to 1 is no, is it possible to check in the server side the Request.ContentLength and prevent the exception/ blank page if the file size
13
10414
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 set of integers stored in an array.It would be a great help if you could provide some code for it.I tried the function fscanf but by that I am able to read only the first integer of the text file.Please help me.
0
9199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8899
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7785
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6550
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5884
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.