File aFile = anotherfile.toPath().getParent().resolve(newname).toFile(); to Java 1.6

Posted on 2014-08-26
Last Modified: 2014-08-29

I am trying to convert a Java application which is implemented in Java1.7 to 1.6
This works fine in 1.7
File aFile = anotherfile.toPath().getParent().resolve(newname).toFile()

Open in new window

but toPath() is not recognized in 1.6

Any fast solution that is compatible with 1.6?

Question by:jazzIIIlove
    LVL 86

    Expert Comment

    Why not just File.getParent/File.getParentFile?
    LVL 12

    Author Comment

    because there is one line above:
       String newname = simpleDateFormat.format(date)+ anotherFile.getName();

    Open in new window

    LVL 86

    Accepted Solution

    because there is one line above: ...

    Sorry - i don't understand your point. In fact the code will be simpler than the nio code

    String newname = simpleDateFormat.format(date) + anotherFile.getName();
    File aFile = new File(anotherfile.getParentFile(), newname);

    Open in new window

    LVL 86

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now