• 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

Merge and split file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have 2 file, a file is text, a file is encrypted, i merge them by

I write a method ReadFile and return String, but part file encrypted is changed.


This is file merge

This is result of method ReadFile

How i can split them that don't throught String??? Thanks a lot of
 
Marshal
Posts: 28235
95
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
When you are reading bytes which don't represent text -- like those encrypted bytes you have at the back end of that file there -- don't use a Reader to read them. Use an InputStream instead, exactly like you did in the first program.
 
ba thong
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks you.
My goal is split file, i can't write method ReadFile(String filename) that return byte[] (can you help me ???), then how i can split file form that array byte ??
 
Paul Clapham
Marshal
Posts: 28235
95
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 don't see why you need a ReadFile method which returns an array of bytes. If I understand it correctly, your mushed-together file consists of one set of data, then an "@", then another set of data. So read bytes until you hit the @, and write all of those bytes (except the @) into the first file. Then copy the rest of the bytes into the second file. Sort of like your first program.

By the way, why did you decide to do this? Mashing two kinds of data into a single file is rarely a good idea. I wouldn't do that if I had to store the text and the encrypted data, I would just store them in two separate files. And not only because it's hard to write a program to split the two, also because you now need a rule which says you can't have the "@" character in the text half of the file.
 
ba thong
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks you a lot of
I merge file because i 'm doing about digital signature. i need encrypt file root document and file digital signature then i ecrypt them by public key of receiver. Do you have idea for me ??? Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic