Commit 86725ee2 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch16] Example code from the book

parent 12afca46
Loading
Loading
Loading
Loading
+4 −5
Changes for src/main/java/ch16/Install.java: 4 added lines, 5 removed lines.
Original line number Diff line number Diff line
package ch16;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.*;
import java.nio.file.*;

public class Install {
  public static void main(String[] args) {
@@ -18,8 +17,8 @@ public class Install {
      Files.createDirectory(myPath3);
      Files.move(mySource, myPath3.resolve(mySource.getFileName()));
      Files.move(myMedia, myPath2.resolve(myMedia.getFileName()));
    } catch (Exception e) {
      System.out.println("got an nio exc");
    } catch (IOException e) {
      System.out.println("Got an NIO Exception" + e.getMessage());
    }
  }
}
 No newline at end of file
+1 −1
Changes for src/main/java/ch16/QuizCardPlayer.java: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class QuizCardPlayer {

  private void loadFile(File file) {
    cardList = new ArrayList<>();
    currentCardIndex = 0;
    try {
      BufferedReader reader = new BufferedReader(new FileReader(file));
      String line;
@@ -89,7 +90,6 @@ public class QuizCardPlayer {
    } catch (IOException e) {
      System.out.println("Couldn't write the cardList out: " + e.getMessage());
    }

    // now time to start by showing the first card
    showNextCard();
  }
+8 −0
Changes for src/main/java/ch16/Snippets.java: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,4 +11,12 @@ public class Snippets {
      }
    }
  }

  void testSplit() {
    String toTest = "What is blue + yellow?/green";
    String[] result = toTest.split("/");
    for (String token : result) {
      System.out.println(token);
    }
  }
}