Last active
January 3, 2016 12:29
-
-
Save mzsanford/8463143 to your computer and use it in GitHub Desktop.
Testing `getBytes`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mzsanford; | |
import java.util.*; | |
public class Foo { | |
public static void main(String [] args) throws Exception { | |
String str = null; | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Starting scanner ..."); | |
while (str != null) { | |
byte[] bytes = str.getBytes("ASCII"); | |
System.out.println("Dumping '" + str + "'"); | |
for (int i=0; i < bytes.length; i++) { | |
System.out.println(" " + i + ": " + bytes[i]); | |
} | |
str = sc.nextLine(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Starting scanner ... | |
^H # Unicode Mac keyboard Alt+0008 | |
Dumping ' | |
0: 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment