1

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
8
  • 2
    Use Apache Commons IO or Guava. Or use java.io classes directly. Commented Nov 25, 2013 at 14:57
  • 2
    Well, have you tried looking at the implementations of either of these methods? Also, the first line can probably be replaced with new FileOutputStream(path) and the second line can be replaced with outputRoot.mkdirs() Commented Nov 25, 2013 at 14:57
  • Out of curiosity - why would you do this? Commented Nov 25, 2013 at 15:29
  • @AndreyChaschev I have a library written for Java 1.7 and my servers have 1.6. I do not change the server's Java version and I have to use that library. Commented Nov 25, 2013 at 15:41
  • @SotiriosDelimanolis what do you mean with java.io classes? Commented Nov 25, 2013 at 15:42

1 Answer 1

1

You can replace the first line with:

OutputStream fileStream = new FileOutputStream(path);

And you could replace the second line with:

outputRoot.mkdirs();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.