Skip to content

Choose a reader

ReaderService.listReaders() returns the reader names known to PC/SC. You can list readers while no tag is on them.

import com.rvi.service.ReaderService;
ReaderService.listReaders().forEach(System.out::println);

Pass the exact name to ReaderService.create(String). Reuse the name reported by the current machine instead of assuming every installation uses the same reader name.

import com.rvi.service.IReaderService;
import com.rvi.service.ReaderService;
try (IReaderService reader = ReaderService.create(readerName)) {
reader.connect();
System.out.println(reader.readContents());
}

In this snippet, readerName is the name selected from the first call. Creating the service selects a reader. Connecting opens the card connection. When the user changes readers, close the old service before opening the next. Only one SocialCard-owned connection per reader can be open at once.

A desktop app can listen for tag insertion and removal with ReaderMonitor. Keep blocking reader work on a background thread. See the published Javadocs for the monitor API and lifecycle.