Please help me in Printing a text file :-(

Hi,
I have asked this question 3 times, but I didnt get any reply. Can someone please help me in printing a text file to a printer using java. I am able to print it but the problem is the whole file is printed in a messy way. Is there any method in java that prints the text file exactly how it is?
Thank u very much.

JavaWorld has a series of articles on how to print using Java: http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html

Similar Messages

  • I'm trying to setup a printer go wireless through my airport extreme, but every time I try to print the printing file gets paused. I'm in loop. PLEASE HELP! (The printer is a Brother 7020  monochrome)

    I'm trying to setup a printer go wireless through my airport extreme, but every time I try to print the printing file gets paused. I'm in loop. PLEASE HELP! (The printer is a Brother 7020  monochrome)

    I had the exact same problem
    It turns out I was using a 20 foot USB cable between the printer and the Airport Extreme and the signal had become to weak to work. Try using nothing more than a 6 foot cable or try a new cable

  • How to print a text file with pagebreak.......

    hi to all,
    i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.

    hi to all,
    i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.

  • How to print a text file with long lines?

    I am trying to print a text file which contains many long lines. I find that the long lines are truncated on the printouts. How do I wrap up these long lines? Could you give me some examples?
    Thank you very much!

    Here's an example. The "\n" makes anything after it go to the next line. I hope this helps. Look at the Private void getTable() section.
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class LabNine extends Frame implements ActionListener, WindowListener {
         private TextField txtInfo;
         private List lstInfo;
         private Button btnAddInfo;
         private BorderLayout borderlayout;
         private Connection databaseConnection;
         Statement statement;
         ResultSet resultSet;
    public LabNine( ) {
         super("Lab Nine");
         // addWindowListener to close application
         addWindowListener(this);
         // create layout
         borderlayout = new BorderLayout();
         setLayout(borderlayout);
         // create text field so the file input that is selected will be seen in here
         txtInfo = new TextField();
         txtInfo.setEnabled(false);
         Color color = new Color(255, 136, 183);
         txtInfo.setBackground(color);
         add(txtInfo, BorderLayout.NORTH);
         // create list so the file input can be populated in here
         lstInfo = new List();
         add(lstInfo, BorderLayout.CENTER);
         // create button to add selected input file in the text field
         btnAddInfo = new Button("Add Info");
         btnAddInfo.setBackground(Color.cyan);
         btnAddInfo.setFont(new Font("TimesRoman", Font.BOLD, 16));
         btnAddInfo.addActionListener( this );          
         add(btnAddInfo, BorderLayout.SOUTH);
         // set frame attributes
         setSize(450, 250);
         setResizable( false );
         show();
         // get the table/ get the query
         loadConnection();
         getTable();
    public void actionPerformed(java.awt.event.ActionEvent e) {
         // if add button is pushed then it will check to see if an item was selected.
         // if not, then an error message will be displayed else the selected item will be in the text box
         if ( e.getSource() == btnAddInfo ) {
              if ( lstInfo.getSelectedIndex() == -1 ) {
                   System.out.print( "You have not selected an item" );
              else {
                   txtInfo.setText(( lstInfo.getSelectedItem() ));
    private void getTable() {
         try {
              String query = "SELECT FIRST, LAST, EMAIL FROM Names";
              statement = databaseConnection.createStatement();
              resultSet = statement.executeQuery( query );
              while ( resultSet.next() ) {
                   lstInfo.add( resultSet.getString( "FIRST" ) + " " + resultSet.getString( "LAST") + " " +
                        resultSet.getString( "EMAIL" ) + "\n" );
              statement.close();     
         catch ( Exception e ) {
              System.err.println( e );
    private void loadConnection() {
         // define the data source for the driver
         String sourceURL = "jdbc:odbc:people";
         String username = "";
         String password = "";
         // load the driver
         try {
              // load the drive class
              Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
              // create a connection through the drivermanager
              databaseConnection = DriverManager.getConnection( sourceURL , username, password );     
         catch( ClassNotFoundException cnfe ) {
              System.err.println( cnfe );
         catch( SQLException sqle ) {
              System.err.println( sqle );
    public static void main(java.lang.String[] args) {
         LabNine aLabNine = new LabNine( );
    public void windowActivated(java.awt.event.WindowEvent e) {
    public void windowClosed(java.awt.event.WindowEvent e) {
         // closes the application
         System.exit( 0 );
    public void windowClosing(java.awt.event.WindowEvent e) {
         // closes the application
         System.exit( 0 );

  • How to print a text file using Java

    How can I print a text file using Java without converting the output to an image format. Is there anyway I can send the characters in the text file as it is for a print job? I did get a listing doing this ... but that converted the text to an image format before printing....
    THanks,.

    Hi I had to write a print api from scratch, and I did not convert the output to image. Go and read up on the following code. I know there is a Tutorial on Sun about the differant sections of the snippet.
    private void printReport()
         Frame tempFrame = new Frame(getName());
         PrintJob printerJob = Toolkit.getDefaultToolkit().getPrintJob(tempFrame, "Liesltext", null);
         Graphics g = printerJob.getGraphics();
                    //I wrote the method below for calculations
         printBasics(g);
         g.dispose();
         printerJob.end();
    }This alone wont print it you have to do all the calculations in the printBasics method. And as I said I wrote this from scratch and all I did was research first the tutorial and the white papers
    Ciao

  • Please help me, I mistakenly deleted a file.  How can I retrieve my file?

    PLease help me retrieve my file.  I was rearranging some docs into sub-files and mistakenly deleted the main file, thinking the sub-files would still be there and they are all gone.  Lots and lots of docs.  PLEASE HELP ME,!!!  The File name was "Cardis, Jackets, Ponchos& Tops Patterns.  I was using the new Adobe Acrobat Reader.

    I don't believe you can if the only copy is on your iPad.
    You must make backups of files which you have on your mobile devices. Then restore from the backup. Backups could easily made by uploading them to Document Cloud, or backing up to another device.

  • HT1338 trouble logging into my imac desktop, why wont it accept my valid password?? Please help I need to retrieve important files. Thanks.

    trouble logging into my imac desktop, why wont it accept my valid password?? I was using it fine last night... Please help I need to retrieve important files. Many Thanks.

    Do #5 and #6 here others as needed
    ..Step by Step to fix your Mac
    Most commonly used backup methods

  • Please help i cannot open the pdf files of cic.gc.ca

    please help i cannot open the pdf files of cic.gc.ca

    Hi ooovvvaaaiiisss12345.
    Are you trying to view the pdf's from the browser are after downloading it and viewing via Reader.
    Please let me know the OS and browser you are using.
    Are you able to view the pdf's on other websites?
    Let me know what errors you get while viewing the pdf's

  • Please help : How to print a matrix from the console...

    Hi..
    Please help:
    How to print a matrix on the console , but i want to take all the input from the console.. like...
    if the matrix is of size...
    mxn
    where
    m : row
    n : column
    and the all the elements of the matrix from the console it self... .
    Please help...

    Thanks...
    I am able to print the elements of the array but i am not able to assign those values to the array ....
    How to do that...
    I just did a little change in my code...
    import java.util.Scanner;
    public class CreatingAMatrix {
        public static void main(String[] args) {
         // TODO Auto-generated method stub
         System.out.print("Enter the number of rows: ");
         Scanner scanner1 = new Scanner(System.in);
         int m = scanner1.nextInt();
         System.out.print("Enter the number of coulmns:");
         Scanner scanner2 = new Scanner(System.in);
         int n = scanner2.nextInt();
         System.out.println("The size of the matrix is : " +m+" x "+n );
         int[][] a = new int[100][100];
         for(int i=0;i<=m;i++)
             for(int j =0; j <= n; j++)
              Scanner scanner3 = new Scanner(System.in);
              int o = scanner3.nextInt();
             System.out.println();
         for(int i=0;i<=m;i++)
             for(int j =0; j <= n; j++)
              System.out.print(a[i][j] + "\t");
             System.out.println();
    }I am getting an output as this
    output:
    Enter the number of rows: 2
    Enter the number of coulmns:1
    The size of the matrix is : 2 x 1
    1
    2
    1
    2
    3
    5
    0     0     
    0     0     
    0     0     
    how should i assig those input values to my array..
    Please help

  • How to compare two files in java & uncommon text should print in text file.

    Hi,
    Can any one help me to write Core java program for this.
    How to compare two files in java & uncommon text should print in other text file.
    thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • Please Help Updating FCPX 10.0.8 files to 10.1.1 - Manually Doesn't Work

    Hello all,
    I tried updating all my Events and Projects from FCP 10.1.1 after using it for awhile (explanation below) and it won't recognize them. After studying online, I've put my Final Cut Events and FC Projects folders in my boot internal Movies drive and on the boot of one of my external drives, but still FCP X 10.1.1 won't recognize them - they are visible but greyed out.
    I have been able to import media from those folders, but without the project files it would be back to the drawing board - no good.
    When I first opened FCPX 10.1.1 I only updated 1 project - a full length doc I was working on, because I didn't want to clog the system while working,
    (I had to get a Digital Cinema Print made quick on my system) and because after reading the Read Me First Notes and white papers, it made it clear that I could update my files manually later.
    So far, no go. Please help. I'm of course - like everyone else - on a deadline, and I have at least 10 short films/projects that are in various stages of
    edits that need to be completed.
    Tom Wolsky, you out there? Kevin Monahan? It's been awhile since I needed advice. Yes, I know, operator error...so it goes. Please help anyone.
    Working on an iMac (Late 2012) 3.1 GHz Intel Core i7 with 16BG 1600 Mhz DDR3 Ram on OSX 10.9.3.
    Cheers and thanks to this community.
    Juri

    UUpdating updates volumes. You don't have to select the project or event. They will always be grayed out. Simply select the hard drive you want to update.

  • Please Help!  Can't open pdf files online.

    Several days ago I attempted to update my Adobe Reader.  I'm using a MacBook with OS 10.9.3.  I have a 2.4 GHz Intel Core 2 Duo.  After installing I received an error which says "internal error occurred"  After reading LOTS of websites, I finally used my Time Machine and reloaded the old adobe version.  It works to open pdf files on my computer, however, when I go to websites, it says that I have to accept the adobe legal agreement before the pdf is opened.  So many webpages are locked because I can't figure out where to accept these permissions.  Firefox will open these same web pages, but the screen is filled with distorted writing, all which basically curses adobe.  I believe your software has a virus and I wonder if you've found a fix.  Please help!

    Hello Pat,
    Thank you for your reply, however, when I launch the older Adobe Reader application, it simply opens and does not ask for me to accept the agreement.  When I launch the newer Adobe Reader, I receive an internal error message and then the reader crashes.  I have attempted to re-load the new reader many times, I've deleted all of my old Adobe files including the files located under LIbrary/....  For many days I wasn't even able to open PDF files which are saved on my hard drive.  Using Apple's Time Machine, I was able to restore an older version of Adobe Reader which I can use to open files on my hard drive.  However, with the old reader and with the new reader, I still cannot open files on the internet - many web pages have items that I wish to open (spec sheets for example).  I have to send the links via email to myself and open them on another computer (extremely inefficient and time consuming). 
    I decided to try using Firefox and what I noticed is that when I try to weblinks that are PDF files, they open with distorted lines of text.  When you read the lines of text, there are broken sentences that say odd things (some profanity) that are directed at Adobe.  I won't repeat the lines here.  If someone from Adobe would please contact me directly (you should have my email information), I would greatly appreciate it.  It's obvious that there is a virus in your software. 
    I need help ASAP because my computer is my business computer and I'm really at a halt.  I need to have access to spec sheets which I can no longer open - or even download.  Buying a new computer to fix my Adobe Reader is not an option.
    Please help.

  • Need help in Overwriting result in text file

    Sorry, im new to Labview.
    My situation is
    this.
    I can store the name and the result and i have the index.
    Now
    I'm having a problem on overwriting result i had in text file.
    I
    give you an example.
    Now in my text file i have a name of a
    student and the result.
    i wan to overwrite the result of the
    student.(this is just an example.)
    can someone guide me please?
    really
    need help as this is my school project.
    Thanks!
    i'll attach my program i have done soon.

    you got the wrong idea.
    i do not want to replace the file to a new file.
    what i want was to edit the exsiting file if the same name appear twice.
    Example:
    in my text file i have already had the name of example Tom and result 80
    and now i input the same name and diff result.
    i wan was to overwrite the result. 
    my project was similar to this here is my attachment of my project
    Attachments:
    LOCATOR.vi ‏19 KB
    TESTCAR.txt ‏1 KB

  • Please help me recover a lost PDF file from Adobe Reader XI

    Hi,
    I was filling out a VA form 5655 in Adobe, and twice today, I lost my file and I just cannot type all of this stuff again, because I had to do so much math and typing and more math.  All of a sudden "bloop", it was gone.  When I try to go into file, then revert, revert is not highlighted.  I tried pulling up history and it said there was no history.  I just don't know what else to do, and I need this for the morning.  Please help?  Thanks

    Hi Pat,
    I filled it out directly from the blank PDF online, and never got a chance
    to save the whole document.  I did however save it about 1/2 way through,
    but yet cannot find that 1/2 of the document either.  Thanks.
    MIke

  • Please help! My Itunes says corrupt file and will not open (IMac 2010). I couldn't fix it by reinstalling so I moved it to trash. It will not delete from my trash as it is saying "Japanese.lproj" is in use. I can't delete or open to close it, what do I do

    Please help!
    My Itunes says there is a corrupt file and will not open (IMac 2010). I couldn't fix it by reinstalling ITunes so I moved ITunes to trash. It will not delete from my trash as it is saying "Japanese.lproj" is in use. I have never opened or used "Japanese.lproj". I can't delete ITunes or open ITunes to close the Japanese.lproj, what do I do? Thank you for any help you can provide..

    It will not delete from my trash as it is saying "Japanese.lproj" is in use. I have never opened or used "Japanese.lproj".
    Interesting. This sort of thing is more common on Windows systems. Taken at face value, one of the iTunes program files (one of the Japanese language resources) is damaged.
    I'd try running your Disk Utility over your startup disk. Does it find/repair any damage? If so can you empty your trash and reinstall your iTunes successfully now?

Maybe you are looking for