Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use java.nio.file package in android? [duplicate]

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!

like image 408
Paramananda Avatar asked Sep 24 '13 12:09

Paramananda


People also ask

What is the use of Java NIO package?

Java NIO is a buffer oriented package. It means that the data can be written/read to/from a buffer which further processed using a channel. Here, the buffers act as a container for the data as it holds the primitive data types and provides an overview of the other NIO packages.

What is the difference between file and files in Java?

Files is utility class holding static methods for managing file system, File is class which instances represent single path (with few additional methods allowing manipulating this path).


1 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.

like image 169
Stephen C Avatar answered Sep 20 '22 21:09

Stephen C