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

a 夏天 提交于 2019-11-28 03:34:43

问题


This question already has an answer here:

  • Android import java.nio.file.Files; cannot be resolved 3 answers

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!


回答1:


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.



来源:https://stackoverflow.com/questions/18981757/how-to-use-java-nio-file-package-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!