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();
}
}
}
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.
© 2015 ZIH Corp. All Rights Reserved.