0

I have one small problem. Somewhere I found that I can program LPT port by writing to file "LPT1" But this code doesn't work. It outputs:

1

2

3

Here is my code:

public static void writeByte(byte data, String portName) throws IOException {
        System.out.println("1");
        FileOutputStream port = new FileOutputStream(portName);
        System.out.println("2");
        PrintStream printer = new PrintStream(port);
        System.out.println("3");
        printer.write(data);
        System.out.println("4");
        printer.println('\f');
        System.out.println("5");
        printer.flush();
        System.out.println("6");
        printer.close();
        System.out.println("7");
        port.close();
        System.out.println("8");
}
4

1 回答 1

0

在 Linux 设备下是文件,这就是我问的原因。在 Windows 下,您需要拥有库并处理该库。在您喜欢的搜索引擎中键入“Windows lpt 端口编程”。是示例解决方案。

于 2017-10-24T09:48:33.150 回答