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?

  • Is the player at least defined as a removable disk in the system? - Nofate
  • one
    In Windows, there are no paths starting with Компьютер . - iksuy
  • That's it, as a removable disk is simply not defined. He immediately sent to the "devices and printers." Yes, I understand that there is no such way, therefore I am writing here) - Dmitresso
  • And how did you get this way out? If you enter the properties of any file in the device (via explorer), is there such a way? - iksuy
  • What will return this method to you? File.listRoots() - iksuy

1 answer 1

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 .