(Java)Run lengthencoding is a simple form of data compression. It replaces longsequences of a repeated value with one occurrence of the value anda count of how many times to repeat it. This works reasonably wellwhen there are lots of long repeats such as in black and whiteimages. To avoid having to represent non-repeated runs with a countof 1 and the value, a special value is often used to indicate a runand everything else is just treated as a simple value. For thisexercise you will decompress one line of input at at time assumingthe line was compressed according to the following:
The newline charactersare passed through uncompressed even when there are repeated blanklines. When a run of n>=3 repeated characters, c, is detectedwhere c is NOT a digit, the run will be replaced with #nc. When arun of n>=3 repeated characters, c, is detected where c IS adigit, the run will be replaced with #n#c. The extra # is needed toavoid confusing the repeated digit c with the last digit of the runcount. All other characters (i.e. runs of just 1 or 2 characters)are passed through unmodified. Assume the uncompressed input doesnot contain the symbol '#'. This assumption can be eliminated. Youmight think about how you would do it.
Some examples:
abc decompresses toabc
#3ab#4c decompressesto aaabcccc
abc12#14#3decompresses to abc1233333333333333
Your decoder canassume the input was properly compressed, i.e. no need for errorchecking. Your program must include a public static methoddecompress() that takes one parameter, a String, that is the lineto be decompressed. The method returns the decompressed String.Write Decoder.java to answer this question.