• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Separate merged binary files

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Can anyone please guide in separating 2 binary files using java api which got merged into 1 file.(appended one after the other). The file content is encoded in charset iso-8859-1.
Is there any standard way to separate individual binary files which were merged into one?

Thanks in advance,
Ravi
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's just reading the contents, and writing to one FileOutputStream first, then close it and write to another FileOutputStream next. The problem will be in finding where to split.
 
ravi D shankar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you give me some info on how I can identify where to split a merged binary file using java api?

Thanks in advance,
Ravi
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well no, to be honest I can't. Like I said, that's the hard part.

What may also be important is to know what the file types should be; do you know? It may help in recognizing the headers inside the files.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to know that too.
 
ravi D shankar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

The filetype I have is conventionally encrypted PGP/GnuPG file.
2 encrypted files have been merged into 1.
If the file format were to be ASCII, it would have been easy to separate them.
We are facing difficulties with the binary file.

Thanks
Ravi
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, let's just put Java aside for a moment.

Is this one particular file you're trying to recover the data from? And do you have the encryption key for the first file of the two? If so, here's what you do:

1) Run gpg to decrypt the combined file, supplying the key as needed. That will give you the first decrypted file. You'll get a warning about tampering because of the extra data but it will work.

2) Encrypt the first file using gpg again using the same key. Note the size of the file in bytes. That tells you the offset of the second file within the combined file!

3) Read the combined file in a Java program, skip that number of bytes from the beginning, and then write the rest to another file.

4) Decrypt that second file, if desired.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic