Print a file on the server on a local printer

Discussion in 'Java' started by priyadar@gmail.com, Oct 13, 2006.

  1. Guest

    Hi all

    I have a very wierd situation - My intranet based application connects
    to a external application via internet and gets a file as a response -
    which it then sucessfully stores on the server. However I need to print
    this file on a local thermal printer. My problem is that while the file
    is saved on the server - it wont get downloaded to my local machine OR
    PRINT command to print the server file wont work coz the server doesnt
    know abt the printer. I tried copying the file by opening a
    URLConnection to the server and then trying to copy - but that wont
    work either. Any ideas abt how I may get this to work.
    The code I am using to copy is

    {
    URL url = new URL(serverFileName);
    File file = new File( localFileName );
    if ( !file.exists() )
    {
    boolean a = file.createNewFile();
    if (a) {logger.info("file creation sucessful");}
    }

    URLConnection urlC = url.openConnection();
    InputStream is = url.openStream();
    System.out.flush();

    FileOutputStream fos=null;
    fos = new FileOutputStream(file);
    int oneChar, count=0;
    while ((oneChar=is.read()) != -1)
    {
    fos.write(oneChar);
    count++;
    }
    is.close();

    fos.close();
    logger.info(count + " byte(s) copied");

    Any help would be highly appreciated

    - PD
    , Oct 13, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robin Dindayal

    Print rendered .aspx page to server's printer

    Robin Dindayal, Jul 23, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    597
    Robin Dindayal
    Jul 25, 2003
  2. Samuel Lee
    Replies:
    0
    Views:
    499
    Samuel Lee
    Nov 11, 2003
  3. =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcg

    Print Label on LOCAL Zebra Printer from WEBSITE Inventory DB

    =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcg, Apr 25, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    1,362
    Alexey Smirnov
    Apr 26, 2007
  4. keto
    Replies:
    0
    Views:
    897
  5. Replies:
    5
    Views:
    131
Loading...

Share This Page