First you will need to find out how many frames per second (sample rate) your audio was generated and what the proper bit rate, knowing these values you can develop an algorithm to encode ".RAW" for any other type, as long as you know the steps required to encode the audio extension of interest, this is not a simple task, there must be some ready class that performs encoding but never looked for anything like that in Java, the algorithm to encode files from raw to wav is not very complex ...
The simplest thing to do is to use some conversion software that accepts command line inputs to perform the conversion, I recommend sox
Here is an example of how to use:
sox -r 8000 –bits 16 –encoding signed-integer –endian big -t raw original.RAW convertido.wav
This example converts a raw file written in 16 bits and sampled at 8000 hertz to the extension ".wav"