Ascii to string in java

Java convert ascii to string java example

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.w3schools;
public class ASCIIToString {
public static void main(String args[]){
try {
int num[] = {66, 118, 98, 75};
String str =null;
for(int i: num){
str = Character.toString((char)i);
System.out.println(str);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.w3schools; public class ASCIIToString { public static void main(String args[]){ try { int num[] = {66, 118, 98, 75}; String str =null; for(int i: num){ str = Character.toString((char)i); System.out.println(str); } } catch (Exception e) { e.printStackTrace(); } } }
package com.w3schools;

public class ASCIIToString {
  public static void main(String args[]){
	try {
             int num[] = {66, 118, 98, 75};
             String str =null;
             for(int i: num){
               str = Character.toString((char)i);
               System.out.println(str);
             }
	} catch (Exception e) {
		e.printStackTrace();
	}
  }
}

Output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
B
v
b
K
B v b K
B
v
b
K

Download this example.