JavaFlacEncoder2 attached to the first post will encode 8,16,24 and possibly 32 bit files, although I haven't found a player that will play 32bit files so can't test it.
Files encoded > 16 bit and 44100 hz may or may not work on all devices, the input files will be very large and it will take a significant amount of time. You may need to consider moving the process to it's own thread if you want to use it on anything but a small file.