Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to convert a hexadecimal file into a readable file in android.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 168
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: