java获取便携设备名,Windows上的便携式设备路径

I've actually got an Windows/Java Question. I've got a plugged-in device which I want to access via Java. Normally you can access an e.g. USB-Stick via the Drive letter... but this tablet is displayed by Windows as a "Portable Device"... which means, that the Path is something like "Computer\Archos 5S" and there is no Drive letter.

I want to access a file on this device via Java, but I am not able to figure out the correct path to it. There is a similar question out there, but without a productive answer. Or is there another way to access this device via Java?

Actually I've not solved this problem... I am still not able to access such a device via java.

At the moment I am trying to access a windows ShellFolder in Java.

A Shellfolder like: "Shell:::{35786D3C-B075-49b9-88DD-029876E11C01}"

Is this possible with Java?

Recently I uncovered the sun.awt class "ShellFolder"... is this the wanted feature?

thanks for your help

Ripei

解决方案

The solution to above problem using JMTP library on https://code.google.com/p/jmtp/

Here is my code

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();

}

}

Do not forget add jmtp.dll files (that comes up with jmtp download) as a native library. For more info, see my answer on Including Native Library in Netbeans.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值