Source Code : Printing a File
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Printing a File

import java.io.*;
import javax.comm.*;
public class PrintFile {
public static void main(String args[]) throws Exception {
if (args.length != 2) {
System.err.println("usage : java PrintFile port file");
System.err.println("sample: java PrintFile LPT1 sample.prn");
System.exit(-1);
}
String portname = args[0];
String filename = args[1];
// Get port
CommPortIdentifier portId = CommPortIdentifier
.getPortIdentifier(portname);
// Open port
// Requires owner name and timeout
CommPort port = portId.open("Java Printing", 30000);
// Setup reading from file
FileInputStream fis = new FileInputStream(filename);
BufferedInputStream bis = new BufferedInputStream(fis);
// Setup output
OutputStream os = port.getOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(os);
int c;
while ((c = bis.read()) != -1) {
bos.write(c);
}
// Close
bos.close();
bis.close();
port.close();
}
}
Thank with us