Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
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}]",""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.