Solved

To connect a printer

Posted on 1997-12-16
1
398 Views
Last Modified: 2011-10-03
How to print a report in a printer through a java program
0
Comment
Question by:geostp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
jpk041897 earned 0 total points
ID: 1231661
To print to a printer, you can open a file which name is the printer device. For example, suppose that your local
     laser printer device is "lpt1", you can do it like this:

     private void print(String report)
         {  
           if (report != "") {
         
           PrintWriter out = null;
            try {
              out = new PrintWriter(new BufferedWriter(new FileWriter("lpt1")));
            } catch ( IOException e) {};
         
          System.out.println("Report to be printed is : " + report);
           out.print(report);
           out.flush();
           out.close();
           }

     This code works well. If your printer device is LAN printer, you type command " net use lpt1 [the printer].
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

Suggested Solutions

Title # Comments Views Activity
ejb message driven bean mdb creation steps 2 54
Html Table Looping (part 2) 5 41
glassfish admin console 1 47
program arguments vs VM arguments 4 56
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

734 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