Java Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

Java 7 similar option to java.nio.file.Files in Java 6


I have the following piece of code that uses the java 7 features like java.nio.file.Files and java.nio.file.Paths

I am referring this example

  public void testInsertParam() throws IOException {
String samplePath = "src/test/resources/insert/sample/";
String srcPath = "src/test/resources/tmp/";
String spoonedPath = "src/test/resources/insert/spooned/";
String expectedPath = "src/test/resources/insert/expected/";

File tmp = new File(srcPath);
Files.copy(new File(samplePath), tmp);

SniperSpoon sniperSpoon = new SniperSpoon();
sniperSpoon.compareFiles(srcPath, spoonedPath);

String contentExpected = new String(java.nio.file.Files.readAllBytes(Paths.get(expectedPath)));
String contentSniped = new String(java.nio.file.Files.readAllBytes(Paths.get(srcPath)));


assertEquals("should be the same", contentExpected, contentSniped);

Now I have to run the the same code on Java 6 , what are the best possible alternatives other than using FileReader ?

Amandeep Singh 6 months ago
  • Whitelisted Links