Home » Android » How to use java.nio.file package in android?

How to use java.nio.file package in android?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I want to create a file manager application for Android using java.nio.file API which is the part of JDK7. I think this (java.noi.file)API contains easy solutions to design file manager application where JDK6(IO) and apache commons IO API does not have the same facility.

Please give some solution, how I use the JDK7 (IO) in android application.

Thanks!

How to&Answers:

Originally: the simple answer was that you can’t do it. Android is Java 6 based, and (AFAIK) there is no backport of Java 7’s java.nio.file classes to Android.

(That’s not surprising. Porting java.nio.file would entail significant changes to the Davlik VM’s native code libraries.)

Updated: according to the Android javadocs, support for the java.nio.file package was added to Android in API level 26. That corresponds to the Oreo release which came out in August 2017.


Can you tell me that what API should I use for my requirements. ( My requirement is File operation like : Cut|copy|delete on files and directories);

Prior to Android 26, I suggest you just use the java.io.File class for things like making directories, renaming files, and so on, and then implement the “higher level” operations such as copying files and directory trees using File.list() and FileInpuStream or FileOutputStream. You could possibly simplify some operations using classes such as the Apache commons DirectoryWalker FileUtils or Guava Files.

However, I’m not sure what you are trying to achieve here. There are already existing “file manager” apps for Android.