I'm making a random file generator that makes a txt with random cartesian points the problem is: when I use the String.format to a number (let's say 4.3), I get "4,3". But I don't want the comma, I don't even know why it makes a comma, there's no use to it at all... The code:
FileWriter fileWriter = new FileWriter(new File("txt.txt"));
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
Random generator = new Random();
int nPoints = generator.nextInt(10)+10;
bufferedWriter.write(""+nPoints);
for (int n=0; n<nPoints; n++){
bufferedWriter.newLine();
String x = String.format("%.1f", generator.nextDouble()*100-50);
String y = String.format("%.1f", generator.nextDouble()*100-50);
bufferedWriter.write(x + " " + y);
}
bufferedWriter.close();
I've solved the problem using replace(",", "."), but I kinda think this is not a good solution, and I want to know if there's any reason to have a comma in the format method.