aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Binary Size of a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Binary Size of a text file" Watch "Binary Size of a text file" New topic
Author

Binary Size of a text file

Susmita Tripathy
Greenhorn

Joined: Oct 30, 2000
Posts: 9
I need to concatenate a number of text files into one file <CONCATENATE.TXT>. The files would be extracted back in a C++ code. As such in the header of <CONCATENATE.TXT> I will have to provide the size of each file I have put there. I need to be able to find the size of each file in binary. I would really appreciate any help on how to do this ,so that the file size can be used by C++ code to extract back individual files from the <CONCATENATE.TXT>.
Thanks a lot,
Susmita
------------------
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12267
    
    1
Java uses the java.io.File class for utility methods such as finding the length of a file.
When you create a File object in order to do the concatenation, use the length() method to get the file length - the value returned is a long, but you will probably be able to cast it to int without any problem. When writing the binary size, remember to look out for byte order problems. If your C++ program is on Windows, it will expect low byte first.
Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Binary Size of a text file
 
Similar Threads
How to store image, audio, video & text files POSTed to JSP page?
How to work with Binary Files?
Problem in framing or understanding the exact approach for the given specification
Excel File opening
Combining Text Files