public
Created

  • Download Gist
gistfile1.java
Java
1 2 3 4 5 6 7 8 9 10
class Main
{
public static void main(String[] args) throws Exception
{
byte[] buffer = {0x53, 0x6f, 0x08, 0x6e, 0x69, 0x01, 0x63}; // 'S', 'o', '^?' (Backspace), 'n', 'i', '^A' (SOH), 'c'
String str = new String(buffer, "US-ASCII");
System.out.println("String: " + str);
System.out.println("Trimmed string: " + str.replaceAll("[^\\p{Print}]",""));
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.