Below is the code to change hexadecimal file to readable format :-
1) Read the Hexadecimal file.
2) Convert the Hexadecimal code to asciii value.
3) Convert the asciii value to readable char format.
int size=15;
char[] mChangedFileCharArray = new char[size];
int chatInt=0;
int positionOfFile=0;
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.app_name) + "/" +sharedPreferenceManager.getOperatorName(getActivity())+"/"+DATA_FILE_NAME);
try
{
FileInputStream in = new FileInputStream(file);
int read;
while((read = in.read()) != -1)
{
String hexString=Integer.toHexString(read);
//reading content in hexadecimal file
int temp2=Integer.parseInt(hexString.trim(), 16);
//changing the hexadecimal to asciii value
mChangedFileCharArray[chatInt] = (char) temp2;
//converting ascii value to readable character value and storing in char array
chatInt++;
positionOfFile++;
}
String readString = String.valueOf(mChangedFileCharArray);
} catch (Exception e) {
e.printStackTrace();
}
0 Comment(s)