File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Splitting a .gz file into specified file sizes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Splitting a .gz file into specified file sizes" Watch "Splitting a .gz file into specified file sizes" New topic
Author

Splitting a .gz file into specified file sizes

manil manohar
Greenhorn

Joined: Mar 13, 2012
Posts: 1
Hello,

This is my first posting, so not sure how apt my description of the issue is..

Below is a program I have written to split a .gz file into files based on the size of each file, the user wants. The parent .gz file is getting split, but not into the size as specified in the code.
For example, in the main I have said I want the parent file to be split into files of size 1 MB. But on executing the code, its getting split into n number of files of different sizes. Can someone help me pin point where I am going wrong? Any help would be great as I have run out of ideas..
Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 180

Use 'long' instead of 'double' for file sizes. Use BufferedInputStream and not DataInputStream & BufferedReader. You are calling fis.read() twice inside the while() loop.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting a .gz file into specified file sizes