[jcifs] Sending data to printer using jCIFS

Naveen Maheshwari naveenmah at gmail.com
Wed Mar 2 04:32:59 MST 2011

This questions has been asked many times but i could not find any reply
I want to send raw data lets say a pcl file to a shared printer on windows.

When I do SmbFile[] files = file.listFiles();
I discover my printer properly, there is no issue

To send the data to the printer i am doing this

        byte[] buf = new byte[1024];
        //test.prn is just any prn file.
        String root = "d:\\test.prn";
        FileInputStream fin = new FileInputStream(new File(root));
        // Always get exception here Parameter incorrect
        SmbFileOutputStream fos = new SmbFileOutputStream(printer);
        int len;
        while ((len = fin.read(buf)) > 0){

where printer is the smbfile of printer i got from listFiles();
I always get exception at parameter incorrect
at SmbFileOutputStream(printer) .

If instead of SmbFileOutputStream() i use

FileOutputStream fos = new FileOutputStream(\\\\\\myPrinter);
PrintStream ps = new PrintStream(fos);

it works fine on windows machine , but i can not use this as I need to print
from android.

Pls. advice what I am doing wrong?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20110302/e8e42bc6/attachment.html>

More information about the jCIFS mailing list