• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to do the encoding and decoding in Java?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I hava a problem in encoding
what I want is , I want to get a enocded value of a String in string format
example: "vas" ----------->"diklildnSIikaOMh"
Has anyone done this ?if so Please give me some details

Thanks in advance
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many ways to do this, in general you could get a ByteOutputStream, wrap it in an ObjectOutputStream, send the String to the OOS, read the bytes from the BOS then convert to a String representation (eg Base64 encode), but this doesn't give the output you specified. (I got 'rO0ABXQAA3Zhcw==')

Implementation is left to the user
 
kavinethere vasan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks david

but stil I have problem in implemetation, I would be greatefull if you help me more , because Im weak in Streams pls

I could not find any read method for BOS in API and also I think BOS mean ByteArrayOutputStream
following think ,I have done and I donnt how to read and convert, because there no read method in the API
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject("vas");
Thanks
kavi
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at the API for the BOS to see how to read the bytes. Once you have the bytes, you need to convert it into a string form (I'm assuming). I chose Base64 encoding since it is fairly common, and used the 'unsupported Sun implementation', if you search the web you should be able to find a free implentation to use.
 
kavinethere vasan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
david
 
The only thing that kept the leeches off of me was this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic