Advertisement
tolord

Untitled

Jan 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package StringSwapper;
  2.  
  3. import java.io.*;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         try (PrintWriter pw = new PrintWriter(new File("output.txt"))) {
  9.             pw.write("Hello, world! Good bye, world!");
  10.         } catch (Exception e) {
  11.             e.printStackTrace();
  12.         }
  13.         try {
  14.             Scanner sc = new Scanner(new FileInputStream(new File ("output.txt")));
  15.             while (sc.hasNext()) {
  16.                 String temp = sc.next();
  17.                 System.out.println(temp);
  18.             }
  19.         } catch (FileNotFoundException e) {
  20.             e.printStackTrace();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement