I am trying to test printing from a Java program. I currently have
Socket s = new Socket(printer_ip, 9100);
PrintWriter pw = new PrintWriter(s.getOutputStream());
pw.println("This is a print test");
pw.println("\n\n\n");
pw.flush();
pw.close();
s.close();
The program does print the text to the printer but it doesn’t eject the paper.
??????
What else am I missing?
I thought after flush() it would recognize that the input is done and it should end the stream after the close().
PrintWriteris not for printing to a literal printer. It’s for writing characters to an output device (usually a console). You should take a look at this tutorial on Java Printing, since it’s a little more complex than your code sample