I'm not a java programmer ( I don't know a bit of java ), I'm a c programmer. But, what you want to do is pretty simple. I found an example that you should check out.
http://www.java2s.com/Code/Java/File-Input-Output/Writesomedatainbinary.htm
You need to modify the code so that you are writing bytes, instead of integers. And you should do it in a loop. If it needs to be random, do as dasblinkenlight suggested. The following snippet I wrote replaces the one in the link I gave you.
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteBinary {
public static void main(String[] argv) throws IOException {
String FILENAME = "binary.dat";
DataOutputStream os = new DataOutputStream(new FileOutputStream(
FILENAME));
for( int i = 0; i < 256; i++ ) os.writeByte( (byte) i );
os.close();
}
}
You should also note that not all ascii values are printable characters. So, when you view the files, you wont be able to count 256 characters. But, you should be able to see the whole alphabet and 0 - 9.