?
Solved

Java/j2ee - Printing the file(without priview) located in Application server.

Posted on 2009-12-21
5
Medium Priority
?
265 Views
Last Modified: 2012-05-08
I have developed a JAVA BEEN which currently able to print the file located in my local PC to my default printer configured (without opening doc).

I have placed the file in remote HTTP/apache server and configured same to access the file using the URL. Which is also working fine
(Like    http://server-name:port/interface-dir/test.pdf.)
.
Now I have requirement to print the same remote file just by passing the input as URL to above java code. ( as http is only the way to access file located on the app server).


Please advise how to achieve this. Or any there way
0
Comment
Question by:mansur_mca
  • 2
  • 2
5 Comments
 
LVL 14

Assisted Solution

by:jb1dev
jb1dev earned 1200 total points
ID: 26098592
How are you printing now?

You can create a File instance with a URL:

File(URI uri)
          Creates a new File instance by converting the given file: URI into an abstract pathname.

Then create a FileInputStream with that file:
FileInputStream(File file)
          Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system.

Read from stream and print.
Or pass this to whatever mechanism you are using for printing.




0
 
LVL 92

Expert Comment

by:objects
ID: 26100010
can you post the code you use to print the file?
0
 
LVL 1

Author Comment

by:mansur_mca
ID: 26101628
ib1dev,

you have given an excellent solution, I will pass to this info to my team and update you.  

please let me know, your above solution can do PDF file printed just like normal file print view format usually we see?

if not, to bring file print on pages like as normal file print ( formatted), is there still method are available.

kindly please let me know the update for the above.

----------------------------------
objects,
If the above soultion does work, then I will let you know about coding
0
 
LVL 92

Accepted Solution

by:
objects earned 800 total points
ID: 26102508
you can't create a File from a http url
you instead need to change your existing code to accept a URL instead of a File
If thats not possible then you need to first download the file
0
 
LVL 14

Assisted Solution

by:jb1dev
jb1dev earned 1200 total points
ID: 26102608
Bah, objects is correct, Sorry about that.
There is a File constructor that takes a URI but this won't work in yoru case. You need to download the file or otherwise handle the URL.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question