file-manager

What's a quick way to test to see a file exists?

隐身守侯 提交于 2019-11-28 16:02:16
I want to quickly check to see if a file exists in my iPhone app's Documents directory (or any path for that matter). I can enumerate through the directory's files, or I can try to open a specific file. What's the fastest way? I just need to know if the file is there or if it does not exist. rein Swift v3: let fileExists = FileManager.default.fileExists(atPath: somePath) Thanks to Nikolay Suvandzhiev . Objective-C (Original): BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:somePath]; 来源: https://stackoverflow.com/questions/1356701/whats-a-quick-way-to-test-to-see-a-file

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

USBdevice recognise as storage device and find path

落爺英雄遲暮 提交于 2019-11-28 01:29:03
How can I detect a mounted device such as a Pen-Drive, that can be used for storage? How can I find the path for the mounted storage device so I may read files from it? I've used following broadcast receiver taking the permission to access mounted device: private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (ACTION_USB_PERMISSION.equals(action)) { synchronized (this) { UsbDevice device = (UsbDevice) intent .getParcelableExtra(UsbManager.EXTRA_DEVICE); if (intent.getBooleanExtra(

How to launch the default (native) application for a given file from Java?

本秂侑毒 提交于 2019-11-27 14:13:13
I am displaying a list of files; i.e. xls, doc, pdf, odt etc., in my Java application (Eclipse RCP). When the user clicks on the file, I want to launch the appropriate (according to what the OS thinks) native application, just like it happens in Windows Explorer or the Finder. And while I am here: It would be nice to also display the same icons that Finder or Explorer use for the different file types. Is there a library or Eclipse plugin for this? Joseph Gordon What you want is java.awt.Desktop : Desktop.getDesktop().open( file ); I have found an API in Eclipse's SWT now that seems to do the

What's a quick way to test to see a file exists?

最后都变了- 提交于 2019-11-27 09:31:03
问题 I want to quickly check to see if a file exists in my iPhone app's Documents directory (or any path for that matter). I can enumerate through the directory's files, or I can try to open a specific file. What's the fastest way? I just need to know if the file is there or if it does not exist. 回答1: Swift v3: let fileExists = FileManager.default.fileExists(atPath: somePath) Thanks to Nikolay Suvandzhiev. Objective-C (Original): BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath

Python - how to find files and skip directories in os.listdir

依然范特西╮ 提交于 2019-11-26 06:37:51
问题 I use os.listdir and it works fine, but I get sub-directories in the list also, which is not what I want: I need only files. What function do I need to use for that? I looked also at os.walk and it seems to be what I want, but I\'m not sure of how it works. 回答1: You need to filter out directories; os.listdir() lists all names in a given path. You can use os.path.isdir() for this: basepath = '/path/to/directory' for fname in os.listdir(basepath): path = os.path.join(basepath, fname) if os.path