I'm just wondering...is it possible to use Java to convert a .mp3 file into a text file of straight up binary (just 1's and 0's)? I figure it would involve the usage of AudioInputStream
and then some method to decode individual bytes, but can someone give me an idea on where to start?
Thanks!
It's certainly possible, but you don't need to use a special audio stream. What you're looking for is to turn any type of file into a file of 1 and 0 characters. I have not tested this code, but the algorithm should be clear.
FileInputStream fin = new FileInputStream(new File(path));
BufferedWriter bw = new BufferedWriter(new FileWriter(otherpath));
byte contents[] = new byte[100];
while (fin.read(contents)!= -1)
{
for (byte b : contents)
for (int x = 0; x < 8; x++)
bw.write(b>>x & 1);
}
Edit: If you just wanted to see what it looks like, you can open any kind of file with a hex editor.