Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Print a file on the server on a local printer

Reply
Thread Tools

Print a file on the server on a local printer

 
 
priyadar@gmail.com
Guest
Posts: n/a
 
      10-13-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print a vs print '%s' % a vs print '%f' a David Cournapeau Python 0 12-30-2008 03:19 AM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Print Label on LOCAL Zebra Printer from WEBSITE Inventory DB =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcgdG9vbHM=?= ASP .Net 4 04-26-2007 07:29 PM
Playing a local mpeg file from a local HTML file... Lyndon HTML 1 07-25-2005 02:21 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57