Use system default printer to print a file out in Java
Description
The following code shows how to use system default printer to print a file out.
Example
/* w w w. ja va 2s .com*/
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] a) throws Exception{
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.print(new File("c:\\a.txt"));
}
}
The code above generates the following result.