I am generating random numbers and want to write them into a file. But its writing them in binary and I am not able to open them using a text editor. How do I write them in Ascii?
Also what is the fastest method to write them into a file? I want to generate 500MB data
import java.io.*;
import java.util.*;
public class BitsToFile {
public static void main(String arg[])
{
BufferedWriter out;
Random num=new Random();
int Size=100;
int x=0;
int y[]=new int[Size];
String S;
try {
out = new BufferedWriter(new FileWriter("randomSample.txt"));
for (int i=0; i<Size; i++)
{
out.write(num.nextInt(2));
}
out.close();
}catch(IOException e)
{
System.out.println("There was a problem:" + e);
}
}
}