我以前写的Android应用
/**
*
*/
package com.example.printertest;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.util.List;
import java.util.Map;
/**
* @ POS小票打印机 网口无驱打印
*
*调用方法 new PrintLine().print(list,map,string);
* @author Btboy1978 QQ: 138027869
*
*/
public class PrintLine {
static String PRINT_IP = "192.168.1.254";
static int PRINT_PORT = 9100;
Socket socket = null;
OutputStream socketOut = null;
OutputStreamWriter writer = null;
String[] Colum_Name = new String[] { "ID", "菜名", "份数", "小计金额" };// 设定小票列标题
/**
* @throws IOException
*
*/
public PrintLine() throws IOException {
// TODO Auto-generated constructor stub
// 建立打印机连接
//
socket = new Socket("192.168.1.254", PRINT_PORT);
socketOut = socket.getOutputStream();
writer = new OutputStreamWriter(socketOut, "GBK");
}
/**
* @param PRINT_DATA
* 小票主要数据
* @param GS_INFO
* 小票附带信息
* @param CAIDAN_SN
* 小票号码
*/
public void print(List