我用的是POS打印机,在JAVA中直接把LTP1当成文件名写进去就可以,现在电脑的并口坏了,用了一条USB转并口的线,端口号变成“USB001”,再也不能当成文件名了,不知道用什么方法可以访问这个USB001端口。  
  如果装上驱动程序是可以的,但是我用的是POS,需要发一些特殊的命令,   不能用驱动程序。
请各位高手指点一下,谢谢了!

解决方案 »

  1.   

    用jUSB试试看,http://jusb.sourceforge.net/举例:
    [code]
    import usb.core.*;
     
    public class ListUSB
    {
        public static void main(String[] args)
        {
            try
            {
                Host   host = HostFactory.getHost();
                Bus[]  bus  = host.getBusses();
                int    total_bus = bus.length;
                for (int i=0; i<total_bus; i++)
                {
                    Device root = bus[i].getRootHub();
                    int total_port = root.getNumPorts();
                    for (int j=1; j<=total_port; j++)
                    {
                        Device device = root.getChild(j);
                        if (device != null)
                        {
                            // 操作USB
                        }
                    }
                }
            } catch (Exception e)
            {
                System.out.println(e.getMessage());
            }
        }
    [/code]
      

  2.   

    import usb.core.*;
     
    public class ListUSB
    {
        public static void main(String[] args)
        {
            try
            {
                Host   host = HostFactory.getHost();
                Bus[]  bus  = host.getBusses();
                int    total_bus = bus.length;
                for (int i=0; i<total_bus; i++)
                {
                    Device root = bus[i].getRootHub();
                    int total_port = root.getNumPorts();
                    for (int j=1; j<=total_port; j++)
                    {
                        Device device = root.getChild(j);
                        if (device != null)
                        {
                            // USB操作
                        }
                    }
                }
            } catch (Exception e)
            {
                System.out.println(e.getMessage());
            }
        }
      

  3.   

     开始 运行 CMD   进入DOS使用命令
           NET    USE    LPT1:    \\ABC\XYZ     /Persistent:YES
                     回车,即可映射出刚才共享的打印机到LPT1端口,在命令行端口运行
      

  4.   

    楼主,我现在也在搞一个前台pos打印的一个项目,我想问一下偻主,你用LPT1直接访问并口打印机是怎么实现的?非常感谢,急切等待中。[email protected]