Skip to content

Instantly share code, notes, and snippets.

@jonvuri
Created November 4, 2012 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonvuri/4012570 to your computer and use it in GitHub Desktop.
Save jonvuri/4012570 to your computer and use it in GitHub Desktop.
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