获得使用Java便携设备

获得使用Java便携设备

本文介绍了获得使用Java便携设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问设备的某些文件(具有的windows CE的在它的应用程序),显示为便携设备在Windows 7中使用Java小程序.. ..

I am trying to access some files in a device (having "windows CE" application in it) that appears as portable device in windows 7 using java applet....

我的设备路径是像

 "Computer\Attari's Device\myfile.txt" 

现在我试图使用相同的地址从它访问文件,但它提供了路径错误或文件未找到。

Now i am trying to access file from it using the same address but it gives path error or file not found.

同样,我用

"\\.\Attari's Device\myfile.txt"

但它导致了同样的错误,告诉我​​如何使用Java小程序访问的便携式设备。

but it resulted in same error tell me how to access portable devices using java applet

当我浏览到连接的设备和文件上右键点击并查看它的属性那么就说明它的位置

When i navigate to connected device and right-click on file and see it's properties then it shows it's location as

Location:  Computer\Attari's Device

此外,当我打开这个文件会被自动放入临时我的电脑的文件。
我使用的签名Applet以及所以没有拒绝的文件访问问题

Also when i open this file it is automatically placed in temp files of my computer.I am using Signed Applet as well so there is no issue of file access denied

我也用

File.listRoots()

但它也没有列出连接便携设备
我用写在便携式设备的一些文件,Java小程序

but it also does not list attached portable devicesI have to write some file in portable device using java applet

推荐答案

我发现

http://code.google.com/p/jmtp/

下面是我的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();

    }
}


DONOT忘记添加jmtp.dll文件(即与jmtp下载来了)作为本机库的更多信息请参阅我的回答对

http://stackoverflow.com/questions/12798530/including-native-library-in-netbeans

这篇关于获得使用Java便携设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 15:00