I'm looking to rewrite my whole .txt file of numbers e.g. 302340372048725280 to 3 0 2 3 4 0 3 7 2 0 4 8 7 2 5 2 8 0. How may I do this?
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class IntSeparator {
public static void main(String[] args) throws IOException {
Scanner scanner;
try {
scanner = new Scanner(new File("src/extremePuzzles.txt"));
PrintWriter spacer = new PrintWriter(new FileWriter("src/extremePuzzles.txt", true));
while (scanner.hasNext()) {
String puzzle = scanner.next();
System.out.println(puzzle);
String splitted = puzzle.replace("", " ").trim();
System.out.println(splitted);
spacer.print(splitted);
}
} catch (FileNotFoundException e) {
System.out.println("file not found!");
}
}
}