This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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

Splitting a .gz file into specified file sizes

manil manohar

Joined: Mar 13, 2012
Posts: 1

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: 727

Use 'long' instead of 'double' for file sizes. Use BufferedInputStream and not DataInputStream & BufferedReader. You are calling twice inside the while() loop.

When I was your age I was toggling in the bootstrap code on the front panel
I agree. Here's the link:
subject: Splitting a .gz file into specified file sizes
It's not a secret anymore!