How to convert a long string into an array for encoding and decoding purposes?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Lyles

    How to convert a long string into an array for encoding and decoding purposes?

    After a message is entered by the user, I must either encode it or decode it. In order to do so, I am supposed to input two strings to represent my table, but am unsure how to convert them to an array to do so.

    private static final String CODE1=
    "HTNZUL5m3lDQch enpIuORws1jPgVt zKWbfBxXSArdayC JkvqGiF2YoM4E";

    private static final String PLAIN =
    "ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz ,.;:";
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    I am not very clear about your question.
    But i give some suggestion as i understood your question.

    Take a character array of length = String length

    Iterate the string and use charAt(index) method and fetch the character at ith position and put it in character array.

    Regards
    Dheeraj Joshi

    Comment

    Working...