Advertisement

06.23.2005 at 04:30AM PDT, ID: 21468145
[x]
Attachment Details

how to convert byte array to char array or string

Asked by rohitdivas in Java Programming Language

Tags: byte, char, convert, string

Hi,
working on JDK 1.5 , having following query:

      i am converting a string to byte array using the code

      byte[] stringToByteArray(String str) {
           int length = str.length();
          byte[] byteArray = new byte[length*2];
          for (int i= 0; i< length; i = i + 2) {
            byteArray[i] = (byte)(str.charAt(i) & 0xff);
           byteArray[i+1] = (byte)(str.charAt(i) >> 8 & 0xff);
        }
        return byteArray;
    }  


  now i am passing this byte array to a method, which encrypt this byte array and return encrypted byte array.
 but i don't know how to convert encrypted "byte array to char array or string."

 using new String( byte[] ) displays some unusual chars.
 i have to dispaly encrypted response in numbers and alphabetical charactres only.

thanksStart Free Trial
[+][-]06.23.2005 at 04:32AM PDT, ID: 14282991

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: byte, char, convert, string
Sign Up Now!
Solution Provided By: objects
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.23.2005 at 04:32AM PDT, ID: 14282996

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.23.2005 at 05:26AM PDT, ID: 14283254

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.23.2005 at 05:27AM PDT, ID: 14283260

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.23.2005 at 05:46AM PDT, ID: 14283417

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.23.2005 at 05:49AM PDT, ID: 14283435

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.23.2005 at 05:50AM PDT, ID: 14283437

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.23.2005 at 05:51AM PDT, ID: 14283445

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.23.2005 at 10:00AM PDT, ID: 14286104

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.15.2005 at 01:26AM PDT, ID: 14448637

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.19.2005 at 10:31AM PDT, ID: 14477402

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32