public interface MagCardReader
package test.zebra.sdk.device.examples;
import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.device.MagCardReader;
import com.zebra.sdk.device.MagCardReaderFactory;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
public class MagCardReaderExample {
public static void main(String[] args) throws Exception {
Connection connection = new TcpConnection("192.168.1.100", TcpConnection.DEFAULT_CPCL_TCP_PORT);
try {
connection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
MagCardReader mcr = MagCardReaderFactory.create(printer);
if (mcr != null) {
String[] trackData = mcr.read(10 * 1000);
System.out.println("Track1: " + trackData[0]);
System.out.println("Track2: " + trackData[1]);
System.out.println("Track3: " + trackData[2]);
}
} catch (ConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
}
Modifier and Type | Method and Description |
---|---|
String[] |
read(int timeoutMS)
Activates the device's magnetic card reader, if present, and waits for a card to be swiped.
|
String[] read(int timeoutMS) throws ConnectionException
timeoutMS
- the amount of time in milliseconds to enable the reader and wait for a card to be swiped.ConnectionException
- if an I/O error occurs.
© 2017 ZIH Corp. All Rights Reserved.