USB Drive Detector

A Java library to get a list of all usb storage devices connected to the computer. It works on the three main operating systems (Windows, Linux and OS X).

License

License

Categories

Categories

Net
GroupId

GroupId

net.samuelcampos
ArtifactId

ArtifactId

usbdrivedetector
Last Version

Last Version

2.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

USB Drive Detector
A Java library to get a list of all usb storage devices connected to the computer. It works on the three main operating systems (Windows, Linux and OS X).
Source Code Management

Source Code Management

https://github.com/samuelcampos/usbdrivedetector/

Download usbdrivedetector

How to add to project

<!-- https://jarcasting.com/artifacts/net.samuelcampos/usbdrivedetector/ -->
<dependency>
    <groupId>net.samuelcampos</groupId>
    <artifactId>usbdrivedetector</artifactId>
    <version>2.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.samuelcampos/usbdrivedetector/
implementation 'net.samuelcampos:usbdrivedetector:2.1.1'
// https://jarcasting.com/artifacts/net.samuelcampos/usbdrivedetector/
implementation ("net.samuelcampos:usbdrivedetector:2.1.1")
'net.samuelcampos:usbdrivedetector:jar:2.1.1'
<dependency org="net.samuelcampos" name="usbdrivedetector" rev="2.1.1">
  <artifact name="usbdrivedetector" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.samuelcampos', module='usbdrivedetector', version='2.1.1')
)
libraryDependencies += "net.samuelcampos" % "usbdrivedetector" % "2.1.1"
[net.samuelcampos/usbdrivedetector "2.1.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.28
com.github.tuupertunut : powershell-lib-java jar 2.0.0
org.projectlombok : lombok Optional jar 1.18.10

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.slf4j : slf4j-simple jar 1.7.28

Project Modules

There are no modules declared in this project.

USB Drive Detector

Build Status | version

A Java library to get a list of all usb storage devices connected to the computer and has the capability of unmount them. It works on the three main operating systems (Windows, Linux and OS X).

Maven dependency

To include this library in your project just use:

<dependency>
    <groupId>net.samuelcampos</groupId>
    <artifactId>usbdrivedetector</artifactId>
    <version>2.1.2</version>
</dependency>

Usage examples

USBDeviceDetectorManager driveDetector = new USBDeviceDetectorManager();

// Display all the USB storage devices currently connected
driveDetector.getRemovableDevices().forEach(System.out::println);

// Add an event listener to be notified when an USB storage device is connected or removed
driveDetector.addDriveListener(System.out::println);

// Unmount a device
driveDetector.unmountStorageDevice(driveDetector.getRemovableDevices().get(0));

Once you invoke addDriveListener, your application keep running because it will internally create an ScheduledExecutorService. To finish your application, just invoke the close method;

    // Shutdown an initialized USBDeviceDetectorManager
    driveDetector.close();

Versions

Version
2.1.1
2.1.0
2.0.4
2.0.2
2.0.1
2.0.0