Byte decoderle new bytegetdecodedlengthrledata int

This preview shows page 5 - 8 out of 10 pages.

byte[] decodeRle = new byte[getDecodedLength(rleData)];int counter;int counter1 = 0;for (int i = 0; i < rleData.length/2; i++){counter = rleData[2*i];for (int j = 0; j < counter; j++){decodeRle[counter1] = rleData[1+(2*i)];counter1++;}}return (decodeRle);}//This method takes a string of data in hexidecimal and converts it into abyte array in decimalpublic static byte[] stringToData(String dataString){byte[] stringToData = new byte[dataString.length()];//This collection of if statements in this for loop converts the datainto decimal from hexidecimalfor (int i = 0; i < dataString.length(); i++){if (dataString.substring(i, i + 1).equals("0")){stringToData[i] = 0;}if (dataString.substring(i, i + 1).equals("1")){stringToData[i] = 1;}
if (dataString.substring(i, i + 1).equals("2")){stringToData[i] = 2;}if (dataString.substring(i, i + 1).equals("3")){stringToData[i] = 3;}if (dataString.substring(i, i + 1).equals("4")){stringToData[i] = 4;}if (dataString.substring(i, i + 1).equals("5")){stringToData[i] = 5;}if (dataString.substring(i, i + 1).equals("6")){stringToData[i] = 6;}if (dataString.substring(i, i + 1).equals("7")){stringToData[i] = 7;}if (dataString.substring(i, i + 1).equals("8")){stringToData[i] = 8;}if (dataString.substring(i, i + 1).equals("9")){stringToData[i] = 9;}if (dataString.substring(i, i + 1).equals("A") ||dataString.substring(i, i + 1).equals("a")){stringToData[i] = 10;}if (dataString.substring(i, i + 1).equals("B") ||dataString.substring(i, i + 1).equals("b")){stringToData[i] = 11;}if (dataString.substring(i, i + 1).equals("C") ||dataString.substring(i, i + 1).equals("c")){stringToData[i] = 12;}if (dataString.substring(i, i + 1).equals("D") ||dataString.substring(i, i + 1).equals("d")){stringToData[i] = 13;}
if (dataString.substring(i, i + 1).equals("E") ||dataString.substring(i, i + 1).equals("e")){stringToData[i] = 14;}if (dataString.substring(i, i + 1).equals("F") ||dataString.substring(i, i + 1).equals("f")){stringToData[i] = 15;}}return (stringToData);}//This method takes a byte array of rle data and converts it into humanreadable datapublic static String toRleString(byte[] rleData){String rleString = "";String[] RLEString = new String[rleData.length];for (int i = 0; i < rleData.length; i++){if (rleData[i] == 0){RLEString[i] = "0";}if (rleData[i] == 1){RLEString[i] = "1";}if (rleData[i] == 2){RLEString[i] = "2";}if (rleData[i] == 3){RLEString[i] = "3";}if (rleData[i] == 4){RLEString[i] = "4";}

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 10 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
NoProfessor
Tags
Do while loop

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture