Search code examples
javajava-7java-6

How to Convert That Java 1.7 Code to Java 1.6?


I am converting an existing Java 1.7 project into 1.6. I have changed diamond operations and try with resources. However 1.7 has some File operations capability that 1.6 does not have. How can I change that lines of code into 1.6:

OutputStream fileStream = Files.newOutputStream(path); //there is no Files class
java.nio.file.Files.createDirectories(outputRoot.toPath()); //there is not toPath() method

also Path class

Solution

  • You can replace the first line with:

    OutputStream fileStream = new FileOutputStream(path);
    

    And you could replace the second line with:

    outputRoot.mkdirs();