Formatting of strings



I'm looking for the best way to combine two strings so that the result
ends with the 2:nd string in position 30-32. The 1:st string is 1 to
30 chars long.

Currently I use the following (untested) code.

char cc[] = new char[33];
for(int i = 0; i < 33; i++) { cc[i] = ' '; } //Make spaces
cc[30] = '/'; // This is the 3 chars for string2
cc[31] = '0';
cc[32] = '0';
string1.getChars(0,string1.length()- 1, cc, 0);
resultString = new String(cc);

I would appreciate suggestions both on the solution (perhaps this is
the best solution) and proper Java coding.

This operation will be used just a few times a day, so the solution
really doesn't matter for the project, but it matters for me trying to
learn Java.

/Ulf
.



Relevant Pages

  • Re: Formatting of strings
    ... 30 chars long. ... resultString = new String; ... the best solution) and proper Java coding. ... really doesn't matter for the project, but it matters for me trying to ...
    (comp.lang.java.programmer)
  • String and Char handling limitations:
    ... Why does Pascal limit functions you can perform on Strings and Chars. ... However that method is causing an infinite loop and there is no way a ...
    (comp.lang.pascal.borland)
  • Re: String and Char handling limitations:
    ... Why does Pascal limit functions you can perform on Strings and Chars. ... However that method is causing an infinite loop and there is no way a ...
    (comp.lang.pascal.borland)
  • Re: Howto Distinguish Prior from KP_Prior
    ... dumped the read chars in hex. ... That's not quite as nifty as the keymap feature, ... few days ago, with strings like: ... So you push the key that generates keysym 0xffb9, rxvt inserts ...
    (comp.os.linux.x)
  • Re: Curses - can I use utf-8 with the form and menu libraries ?
    ... > the form library doesn't accept the strings, ... > isprintreturnes false for those chars. ... buffer which holds the translation (this may be a problem with some ...
    (comp.unix.programmer)