Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.io.PrintWriter;
- public class MyWriter {
- public static void main(String[] args) {
- System.out.println("Starting...");
- String fileName = "numbers.txt";
- try (PrintWriter writer = new PrintWriter(new File(fileName))) {
- int sep = 1;
- for (int i = 0; i < 10; i++) {
- sep++;
- writer.print(i);
- if (sep == 3) {
- writer.write("\n");
- sep = 1;
- }
- }
- } catch (final IOException ex) {
- ex.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement