I am reading a data from .wav file and then converting it into binary format. and then I write those binaries and create a new .wav file. I want that after getting binary format of .wav file I should do little modifications in its LSB's and then write the file from those modified bits.
How should i implement this? I am not getting any way. Please help me as I want to perform stenography through audio file.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class FiletoArrayofBytes
{
public static void main( String[] args )
{
FileInputStream fileInputStream=null;
FileOutputStream fop = null;
File file = new File("C:\\file.wav");
byte[] bFile = new byte[(int) file.length()];
try {
File fileo = new File("c:/newfile.wav");
fop = new FileOutputStream(fileo);
// if file doesnt exists, then create it
if (!fileo.exists()) {
fileo.createNewFile();
}
//convert file into array of bytes
fileInputStream = new FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();
for (int i = 0; i < bFile.length; i++) {
System.out.println(Integer.toBinaryString(0x100 + (bFile[i])).substring(1));
//String a =(Integer.toBinaryString(0x100 + (bFile[i])).substring(1));
int a=bFile[i];
fop.write(a);
System.out.println("\t i am a: " +a);
}
fop.flush();
fop.close();
System.out.println("Done");
}catch(Exception e){
e.printStackTrace();
}
}
}