[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2014-08-26
4
Medium Priority
?
262 Views
Last Modified: 2014-08-29
Hi;

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?

Regards.
0
Comment
Question by:jazzIIIlove
  • 3
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 40285376
Why not just File.getParent/File.getParentFile?
0
 
LVL 12

Author Comment

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

Open in new window

0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 40285945
because there is one line above: ...

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

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

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40293283
:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

867 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