Java 使用具有特定IP地址的打印机在Android中打印
我的问题是,我有一台连接到以太网的打印机,我可以使用打印机的IP地址打印到该打印机,但问题是,打印机在指定的打印行结束时停止打印,因此纸张卡在打印机中Java 使用具有特定IP地址的打印机在Android中打印,java,android,sockets,printing,Java,Android,Sockets,Printing,我的问题是,我有一台连接到以太网的打印机,我可以使用打印机的IP地址打印到该打印机,但问题是,打印机在指定的打印行结束时停止打印,因此纸张卡在打印机中 try { Socket sock = new Socket(ipAddress, 9100); PrintWriter oStream = new PrintWriter(sock.getOutputStream()); oStream.println("HI,test from Android Device
try {
Socket sock = new Socket(ipAddress, 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("HI,test from Android Device");
oStream.println("\n\n\n");
oStream.close();
sock.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
我的代码:
try {
Socket sock = new Socket("192.168.0.131", 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("HI,test from Android Device");
oStream.println("\n\n\n");
oStream.close();
sock.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
只需在行尾添加一个
\f
oStream.println("\n\n\n\f");
这是用于表单提要/新页面的在与进行套接字连接后,我无法打印您的代码 打印机
try {
Socket sock = new Socket(ipAddress, 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("HI,test from Android Device");
oStream.println("\n\n\n");
oStream.close();
sock.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
有没有办法知道打印是否成功?