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
Solved

To connect a printer

Posted on 1997-12-16
1
396 Views
Last Modified: 2011-10-03
How to print a report in a printer through a java program
0
Comment
Question by:geostp
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
V.simple question about Android packages and libraries 1 29
xampp tool 12 56
Facing this issue for maven proxy setting 2 19
mysql jsp example issue 32 48
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

765 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