Created
October 24, 2014 09:51
-
-
Save ratulcse10/4c4bb3dee6f7006c11c7 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package bangla; | |
import javax.swing.JOptionPane; | |
/** | |
* | |
* @author Ratul | |
*/ | |
public class Bangla { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
// TODO code application logic here | |
//receive secretCode as String | |
String secretCodeString = "ক"; | |
//Convert Secret Code from String to Byte Array | |
byte secretCodeBye[]=secretCodeString.getBytes(); | |
//Convert Secret Code from Byte to Int | |
int[] secretCodeInt = new int[secretCodeString.length()]; | |
for (int i=0;i<secretCodeString.length();i++){ | |
secretCodeInt[i]=secretCodeBye[i]; | |
} | |
//Convert Secret Code from Int to Binary | |
String secretCodeBinaryString = new String(); | |
String tempSecretCodeBinary = new String(); | |
for (int j=0;j<secretCodeString.length();j++){ | |
tempSecretCodeBinary=Integer.toBinaryString(secretCodeInt[j]); | |
//Check & Correct the Format of String as 8-Bit Binary | |
if (tempSecretCodeBinary.length()<8){ | |
for (int m=0;m<=8-tempSecretCodeBinary.length();m++){ | |
tempSecretCodeBinary=String.format("0"+"%s",tempSecretCodeBinary ); | |
} | |
} | |
// secretCodeBinaryString=String.format("%s"+"#"+"%s",secretCodeBinaryString,tempSecretCodeBinary); | |
secretCodeBinaryString=String.format("%s"+"%s",secretCodeBinaryString,tempSecretCodeBinary); | |
} | |
System.out.println(secretCodeBinaryString); | |
//$$$$$$Bangla Text receive & Process | |
String secretCode = new String(); | |
for (int i = 0; i < secretCodeBinaryString.length()/8; i++) { | |
int a = Integer.parseInt(secretCodeBinaryString.substring(8*i,(i+1)*8),2); | |
System.out.println(a); | |
secretCode += (char)(a); | |
} | |
System.out.println(secretCode); | |
JOptionPane.showMessageDialog(null, secretCode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment