• 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

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
 
Sheriff
Posts: 28344
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
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
Sheriff
Posts: 28344
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 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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic