Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package StreamsFilesAndDirectories4;
- import java.io.*;
- import java.util.Scanner;
- public class WriteEveryThirdLine {
- public static void main(String[] args) throws IOException {
- String inPath = "input.txt";
- String outPath = "output.txt";
- Scanner in = new Scanner(new FileReader(inPath));
- PrintWriter out = new PrintWriter(new FileWriter(outPath));
- int counter = 1;
- String line = in.nextLine();
- while (in.hasNextLine()) {
- if (counter % 3 == 0) {
- out.println(line);
- }
- counter++;
- line = in.nextLine();
- }
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment