• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to Re-Assembling a splitted file correctly

 
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please have a look at the following code



In here, I am trying to re-assemble a **splited** file, back to its original file. This is how I split it




Now, after re-generating the file, it seems like some parts are missing. For an example, if I re-generated a splitted mp3, some small small portions of sounds are not there / sound is jumping etc. Why is that? Please help!

Another question, I have assigned 30720 as the byte array value. I did this because I failed to set the byte array according to the original size of the particular file which is about to process. I assigned the byte array value as


before, but it didn't work.

Please help me to solve these two issues and re-assemble the splitted file back, correctly. And please note, I have posted this in another location but didn't get any good answers, please help!
 
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just took a quick look at the code. There are probably more bugs, but I don't like this code:



You read some number of bytes from the file, but then you call the writeBlock() method without telling it how many bytes you actually read. And that method simply assumes (perhaps incorrectly) that you read buffer.length bytes.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I just took a quick look at the code. There are probably more bugs, but I don't like this code:



You read some number of bytes from the file, but then you call the writeBlock() method without telling it how many bytes you actually read. And that method simply assumes (perhaps incorrectly) that you read buffer.length bytes.



OK, Thanks a lot for the reply. I really appreciate it. But, how can I do that? Please help!
 
Paul Clapham
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The usual way to pass information to a method is by using parameters.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. I did it. Thanks a lot for the reply.

And for the byte value case, I converted it using parse(xxx) methods.
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic