tuxmartin

Bin string to ASCII chars

Nov 30th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public class BinToASCII {
  2.    
  3.     public static void main(String[] args) {       
  4.         String in = "0101010001100001011010110110111101110110011001010010000001110100011011110010000001101100011010010110111001100101001000000111001101101111011000100110111101110100011011100110100100100000011011110110010001110000011011110110110001100101011001000110111001100101001000000011101000101001";
  5.  
  6.         // http://stackoverflow.com/a/2297450/1974494
  7.         String[] data = in.split("(?<=\\G........)");
  8.  
  9.         for (int i = 0; i < data.length; i++) {
  10.             char pismeno = (char) Integer.parseInt(data[i], 2);
  11.             System.out.print(pismeno);
  12.         }
  13.         System.out.println();
  14.     }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment