package cardreaders;
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.FileOutputStream;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
public class CardReader extends Applet {
Graphics gg;
int pos;
public void init() {
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g)
{
gg = g;
pos = 14;
text( "INITIALIZATION..." );
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
if ( portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
text( "FOUND PORT " + portIdentifier.getName());
}
}
public void text(String t)
{
gg.drawString(t, 10, pos);
pos += 14;
}
}
* This source code was highlighted with Source Code Highlighter .
package cardreaders;
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.FileOutputStream;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
public class CardReader extends Applet {
Graphics gg;
int pos;
public void init() {
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g)
{
gg = g;
pos = 14;
text( "INITIALIZATION..." );
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
if ( portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
text( "FOUND PORT " + portIdentifier.getName());
}
}
public void text(String t)
{
gg.drawString(t, 10, pos);
pos += 14;
}
}
* This source code was highlighted with Source Code Highlighter .
package cardreaders;
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.FileOutputStream;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
public class CardReader extends Applet {
Graphics gg;
int pos;
public void init() {
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g)
{
gg = g;
pos = 14;
text( "INITIALIZATION..." );
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
if ( portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
text( "FOUND PORT " + portIdentifier.getName());
}
}
public void text(String t)
{
gg.drawString(t, 10, pos);
pos += 14;
}
}
* This source code was highlighted with Source Code Highlighter .
package cardreaders;
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.FileOutputStream;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
public class CardReader extends Applet {
Graphics gg;
int pos;
static {
try {
System. out .println( "CardReader {}" );
/* Get DLL from JAR file */
URL res = CardReader. class .getResource( "resources/rxtxSerial.dll" );
InputStream is = res.openStream();
/* Define the destination file */
File dll = File.createTempFile( "rxtxSerial" , ".dll" );
/* Open the destination file */
FileOutputStream fos = new FileOutputStream(dll);
/* Copy the DLL fro the JAR to the filesystem */
byte [] array = new byte [1024];
for ( int i= is .read(array);
i!=-1;
i= is .read(array)
) {
fos.write(array,0,i);
}
/* Close all streams */
fos.close();
is .close();
/* Load the DLL from the filesystem */
System.load(dll.getAbsolutePath());
System. out .println( "CardReader loaded" );
}
catch (Throwable e)
{
e.printStackTrace();
}
}
public void init() {
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g)
{
gg = g;
pos = 14;
text( "INITIALIZATION..." );
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
if ( portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
text( "FOUND PORT " + portIdentifier.getName());
}
}
public void text(String t)
{
gg.drawString(t, 10, pos);
pos += 14;
}
}
* This source code was highlighted with Source Code Highlighter .
package cardreaders;
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.FileOutputStream;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
public class CardReader extends Applet {
Graphics gg;
int pos;
static {
try {
System. out .println( "CardReader {}" );
/* Get DLL from JAR file */
URL res = CardReader. class .getResource( "resources/rxtxSerial.dll" );
InputStream is = res.openStream();
/* Define the destination file */
File dll = File.createTempFile( "rxtxSerial" , ".dll" );
/* Open the destination file */
FileOutputStream fos = new FileOutputStream(dll);
/* Copy the DLL fro the JAR to the filesystem */
byte [] array = new byte [1024];
for ( int i= is .read(array);
i!=-1;
i= is .read(array)
) {
fos.write(array,0,i);
}
/* Close all streams */
fos.close();
is .close();
/* Load the DLL from the filesystem */
System.load(dll.getAbsolutePath());
System. out .println( "CardReader loaded" );
}
catch (Throwable e)
{
e.printStackTrace();
}
}
public void init() {
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g)
{
gg = g;
pos = 14;
text( "INITIALIZATION..." );
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
if ( portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
text( "FOUND PORT " + portIdentifier.getName());
}
}
public void text(String t)
{
gg.drawString(t, 10, pos);
pos += 14;
}
}
* This source code was highlighted with Source Code Highlighter .
package cardreaders;
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.FileOutputStream;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
public class CardReader extends Applet {
Graphics gg;
int pos;
static {
try {
System. out .println( "CardReader {}" );
/* Get DLL from JAR file */
URL res = CardReader. class .getResource( "resources/rxtxSerial.dll" );
InputStream is = res.openStream();
/* Define the destination file */
File dll = File.createTempFile( "rxtxSerial" , ".dll" );
/* Open the destination file */
FileOutputStream fos = new FileOutputStream(dll);
/* Copy the DLL fro the JAR to the filesystem */
byte [] array = new byte [1024];
for ( int i= is .read(array);
i!=-1;
i= is .read(array)
) {
fos.write(array,0,i);
}
/* Close all streams */
fos.close();
is .close();
/* Load the DLL from the filesystem */
System.load(dll.getAbsolutePath());
System. out .println( "CardReader loaded" );
}
catch (Throwable e)
{
e.printStackTrace();
}
}
public void init() {
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g)
{
gg = g;
pos = 14;
text( "INITIALIZATION..." );
java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
while ( portEnum.hasMoreElements() )
{
CommPortIdentifier portIdentifier = portEnum.nextElement();
if ( portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
text( "FOUND PORT " + portIdentifier.getName());
}
}
public void text(String t)
{
gg.drawString(t, 10, pos);
pos += 14;
}
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/71072/
All Articles