we are doing project on image compresion decompression using java.we have already encoded image using base64 encoder after than applied below code.But this java code is not working for image. it works properly for char string but not for image.
StringBuffer dest = new StringBuffer();
for (int i = 0; i < source.length(); i++)
{
int runLength = 1;
while (i + 1 < source.length() && source.charAt(i) == source.charAt(i + 1))
{
runLength++;
i++;
}
dest.append(runLength);
dest.append(source.charAt(i));
}
return dest.toString();