I wrote a simple utility that changes the names of files in a directory. When choosing a directory on hard everything is ok, but it was planned to initially use the utility for files on the player. When I use the player, I catch a NullPointerException , the path is as follows: Компьютер\WALKMAN\Storage Media\MUSIC\ Where to dig?
|
1 answer
Here is a very similar question with answers, I hope, it will help you:
https://stackoverflow.com/a/12841327 Using the JMTP library https://code.google.com/p/jmtp/
package jmtp; import be.derycke.pieter.com.COMException; import be.derycke.pieter.com.Guid; import java.io.*; import java.math.BigInteger; import jmtp.PortableDevice; import jmtp.*; public class Jmtp { public static void main(String[] args) { PortableDeviceManager manager = new PortableDeviceManager(); PortableDevice device = manager.getDevices()[0]; // Connect to my mp3-player device.open(); System.out.println(device.getModel()); System.out.println("---------------"); // Iterate over deviceObjects for (PortableDeviceObject object : device.getRootObjects()) { // If the object is a storage object if (object instanceof PortableDeviceStorageObject) { PortableDeviceStorageObject storage = (PortableDeviceStorageObject) object; for (PortableDeviceObject o2 : storage.getChildObjects()) { // // BigInteger bigInteger1 = new BigInteger("123456789"); // File file = new File("c:/JavaAppletSigningGuide.pdf"); // try { // storage.addAudioObject(file, "jj", "jj", bigInteger1); // } catch (Exception e) { // //System.out.println("Exception e = " + e); // } // System.out.println(o2.getOriginalFileName()); } } } manager.getDevices()[0].close(); } } You must add jmtp.dll files (included in the jmtp download file) as the native library .
- Hmm ... I exported the project to my GitHub, but there is no jmtp.dll file in the project - Dmitresso
- @Dmitresso storage.googleapis.com/google-code-archive-downloads/v2/… - there is - CodeGust
|
Компьютер. - iksuyFile.listRoots()- iksuy