Reputation: 69
If I was to try to make a program that outputs .Flac files in Java, Flac-format, It appears that I would need to output values less than a byte. Is it even possible to output values less than a byte such as a nybble or a 5-bit number?
Upvotes: 0
Views: 94
Reputation: 69
In the end I think I can do this using bit shifting and logical commands such as & and | opperators.
Upvotes: 0
Reputation: 44338
ImageOutputStream.writeBits should do what you want.
You create an ImageOutputStream using the ImageIO.createImageOutputStream method:
Path flacPath = Paths.get(filename);
try (ImageOutputStream out = ImageIO.createImageOutputStream(
new BufferedOutputStream(Files.newOutputStream(flacPath)))) {
out.writeBits(0b1110101011, 10);
// etc.
}
Upvotes: 1