Use FileOutputStream to write the bytes to a file.
import java.io.FileOutputStream;
public class Main {
public static void main(String[] argv) throws Exception {
byte[] vals = { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 };
FileOutputStream fout = new FileOutputStream("Test.dat");
for (int i = 0; i < vals.length; i += 2)
fout.write(vals[i]);
fout.close();
}
}
Related examples in the same category