Corporate
 
 
Zebra条码标签打印机常见问题解决方案> 105SL
 
解决方案# 16014: 网络打印的JAVA例程
知识

通过网络连接打印的JAVA例程

以下例程是一个简单的JAVA程序来说明在通过网络连接通讯时如何使用JAVA程序来打印。

import java.io.*;
import java.net.*;
class TCPClient
{
public static void main (String argv[]) throws Exception
{
// The line below illustrates the default port 6101 for mobile printers 9100 is the default port number
// for desktop and tabletop printers
Socket clientSocket=new Socket("10.17.50.105",6101);

DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream() );
//The data being sent in the lines below illustrate CPCL one can change the data for the corresponding
//language being used (ZPL, EPL)

outToServer.writeBytes("! 0 200 200 203 1" + '\n' + "CENTER" + '\n');
outToServer.writeBytes("TEXT 0 3 10 50 JAVA TEST" + '\n' + "PRINT" + '\n');

clientSocket.close();
}
}

 
上海京威电子科技有限公司. All Rights Reserved. 电话:021-6432.7555 传真:021-64329452 。