Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Re-Assembling a splitted file correctly  RSS feed

 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • 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!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • 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: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual way to pass information to a method is by using parameters.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!