usb detection

Ads

 
 

Share on Google+Share on Google+

sabeer
usb detection
3 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners

i want to detect usb device using javacode

Ads
View Answers

June 9, 2012 at 4:50 PM


try this:

import java.io.*;
import javax.swing.*;
public class DetectWin extends JFrame
{
    JPanel loginPnl = new JPanel();
    JTextField Dfield = new JTextField("", 20);
    
    DetectWin()
    {
        super("AUTHORIZATION");
        setSize(350, 100);
        setLocation(400, 300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        add(loginPnl);
        setVisible(true);
        setResizable(false);
        
        loginPnl.add(Dfield);
        String[] letters = new String[]{ "A", "B", "C", "D", "E", "F", "G", "H", "I", "Z"};
        File[] drives = new File[letters.length];
        boolean[] isDrive = new boolean[letters.length];

        for ( int i = 0; i < letters.length; ++i )
            {
            drives[i] = new File(letters[i]+":/");

            isDrive[i] = drives[i].canRead();
            }

         Dfield.setText("Waiting for devices....");

         while(true)
            {
            for ( int i = 0; i < letters.length; ++i )
                {
                boolean pluggedIn = drives[i].canRead();

                if ( pluggedIn != isDrive[i] )
                    {
                    if ( pluggedIn )
                    	Dfield.setText("Drive "+letters[i]+" has been plugged in");
                    else
                    	Dfield.setText("Drive "+letters[i]+" has been unplugged");

                    isDrive[i] = pluggedIn;
                    }
                }

            try { Thread.sleep(100); }
            catch (InterruptedException e) { }
            }
    }
    public static void main(String args[])
    {
        DetectWin AUTHORIZATION = new DetectWin();
    }
}



January 30, 2013 at 7:30 AM


hiii...

i tried this program but cannot read or detect my USB device. can you explain me, why...?

tq



February 25, 2013 at 8:40 AM


Hiii, nice posting...

i tried this code and running more than 5 minutes but can not read or detect my USB device. i'm using windows 7-64 bit, netbeans 7.1.2 and my device using USB type B connected to PC using USB type A.

can you explain me, why...?

best regards

-kiper-


Ads









Related Tutorials/Questions & Answers:
usb detection
usb detection  i want to detect usb device using javacode
unique manufacturing id of a usb flash drive.
unique manufacturing id of a usb flash drive.  I need code for java application to read the unique manufacturing id of a usb flash drive. Please help me ? thanking you
Advertisements
JMF WebCam detection problem - Framework
JMF WebCam detection problem  Hello friends, I am using JMF to operate my web cam.My usb webcam works perfectly with JMF, I used it in JMStudio... = CaptureDeviceManager.getDeviceList( null ); my USB "webcam" is detected however when i
VoIP USB Phone
VoIP USB Phone          A Corinex VoIP USB Phone A USB phone which can... included in the USB phone packaging to be able to use this software
face detection and face recognition
face detection and face recognition   hi,i will create a project detection and recognition of face in java , i create the face detection using opne... will send the part of face detection if you want help me please
Version of com.51degrees>device-detection dependency
List of Version of com.51degrees>device-detection dependency
php browser detection script - PHP
php browser detection script   I need a browser detection script in PHP. I am creating my application compatible to firefor, mozila and IE too
detection of the operating system on the client machine
detection of the operating system on the client machine  How to detect the operating system on the client machine
Java Circle to Circle collision detection
Java Circle to Circle collision detection  Java Circle to Circle collision detection
java collision detection between two images
java collision detection between two images  java collision detection between two images
Collision Detection between two images in Java
Collision Detection between two images in Java  Collision Detection between two images in Java
Maven Dependency device-detection >> 3.2-beta-7
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2-beta-7 in your project
Maven Dependency device-detection >> 3.2.13.9
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.13.9 in your project
Maven Dependency device-detection >> 3.2.3.5-beta
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.3.5-beta in your project
Maven Dependency device-detection >> 3.2.4.5
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.4.5 in your project
Maven Dependency device-detection >> 3.2.9.2
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.9.2 in your project
Maven Dependency device-detection >> 2.3.14.2
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version2.3.14.2 in your project
Maven Dependency device-detection >> 3.2.10.4
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.10.4 in your project
Maven Dependency device-detection >> 3.2.12.4
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.12.4 in your project
Maven Dependency device-detection >> 3.2.14.2
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.14.2 in your project
Maven Dependency device-detection >> 3.2.2.20-beta
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.2.20-beta in your project
Maven Dependency device-detection >> 3.2.4.3
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.4.3 in your project
Maven Dependency device-detection >> 3.2.4.3-beta
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.4.3-beta in your project
Maven Dependency device-detection >> 3.2.6.1
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.6.1 in your project
Maven Dependency device-detection >> 3.2.8.1
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection version3.2.8.1 in your project
Maven Dependency device-detection >> v3.2.11.3
You should include the dependency code given in this page to add Maven Dependency of com.51degrees >> device-detection versionv3.2.11.3 in your project
how to run java program that has several classes under package from usb drive?
how to run java program that has several classes under package from usb drive?  I have an assignment where I have to submit my code in flash drive. I did all coding in eclipse and getting all output. I tried running it through
error detection - Java Beginners
{ public static void main (string[] args) { Queue q=new