0

I have a String variable that receives the different values, I need to append the different values received in the same variable, I have used StringBuilder but I can't append, how can I do that?

private void receive(byte[] data) {
    String msg = new String(data);
    StringBuilder sb = new StringBuilder();
    sb.append(msg);
    Log.e("DEBUGRX-->", String.valueOf(sb));
}
w1ll
  • 63
  • 1
  • 6

2 Answers2

1

You can use StringBuilder like this way

private void receive(byte[] data) {
    StringBuilder msg = new StringBuilder(data);
    msg.append(msg);
    Log.e("DEBUGRX-->", msg.toString());
}
Bhargav Thanki
  • 4,924
  • 2
  • 37
  • 43
0

Use StringBuilder Class.

StringBuilder sb = new StringBuilder();
sb.append("Some String");
sb.append("Some String");

Like this, it is simple!

Meet Prajapati
  • 416
  • 5
  • 9