Printwriter cannot print whole document

Hi
I have created a small code that doesnt work.
I have made contact to a file to read from, and a file to write to. At the moment i�m just trying to move the whole content line by line to the new document.
However, the output stops before the file is read through.
As you can see in my code, i am printing to both system.out and the outputfile.
It works fine with System.out
Can anybody explain this! i�m thinking it has something to do with a buffer of some sort.
Thanks Carsten
* Main.java
* Created on 5. oktober 2007, 20:15
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package generator;
import java.io.*;
import java.util.Scanner;
* @author carsten
public class Main {
    /** Creates a new instance of Main */
    public Main() {
     * @param args the command line arguments
    public static void main(String[] args) throws IOException {
       //open stream
       FileReader reader = new FileReader("C:\\opcodes.txt");
       Scanner in        = new Scanner(reader);
       PrintWriter out   = new PrintWriter("C:\\opcodes_backup.txt");
       //as long as line is not empty
       while (in.hasNextLine())
           String line = in.nextLine();
           System.out.println(line);
           out.println(line);
}

The opcodes.txt document is about 80000 characters on 3300 lines
i changed the program to only find lines that started with "a" and ended with ".html" - then print those to the document and system.out - again it works fine for system.out, but now nothing is being written to opcodes_backup.
Uploaded docs to http:www.carstenhoyer.dk/opcodes.zip
/Carsten
* Main.java
* Created on 5. oktober 2007, 20:15
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package generator;
import java.io.*;
import java.util.Scanner;
* @author carsten
public class Main {
    /** Creates a new instance of Main */
    public Main() {
     * @param args the command line arguments
    public static void main(String[] args) throws IOException {
       try
           //open stream
           FileReader reader = new FileReader("C:\\opcodes.txt");
           Scanner in        = new Scanner(reader);
           PrintWriter out   = new PrintWriter("C:\\opcodes_backup.txt");
           //as long as line is not empty
           while (in.hasNextLine())
               String line = in.nextLine();
               if(line.startsWith("a") && line.endsWith(".html"))
                   System.out.println(line);
                   out.println(line);
       catch (IOException exception)
           System.out.println("Error processing file: " + exception);
}Edited by: Carsten78 on Oct 6, 2007 2:12 AM

Similar Messages

  • Successfully downloaded and installed Adobe Reader on my PC ... ( Windows 7 home premium (64 bit) OS).  Cannot print adobe documents... Error message indicates need to install plug-in for adobe reader for windows 7 home premium (64 bit) OS               

    Cannot print adobe documents ... Error message indicates a need to install plug-in for adobe reader.
    Please advise how/where to locate the required adobe reader plug-in...
    Thank you,
    Joe Curcio

    What is the full and exact message you are getting?
    If the PDF contains Rich Media, the Flash Player plugin may be required: http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe

  • I cannot print word documents but can print all other documents

    Since updating my virus checker I cannot print word documents. I can print all other documents

    At this point my suggestion is to do a full uninstall of the old print driver and an install of the most recent version print driver which you can obtain at:
    http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=228&lc=en&cc=us&dlc=en&sw_lang=&product=40664...
    Please follow the uninstall procedure before installing the new driver.
    Regards,
    Eric
    I am an HP employee.

  • I cannot print a document I created on the Beta of Pages through iCloud.

    I have an iMac Mid 2007.  I have installed OS X Yosemite, Version 10.10.l  I created a document on Pages, and was unable to access it.  I accessed it via iCloud, the Beta Version of Pages, and was able to edit it.  Now I cannot print it.  Any suggestions?

    When you installed Pages v5, it automatically moved the older Pages ’09 v4.3 into /Applications/iWork '09 folder. If you want normal comment interoperability, you are advised to resume using the older version of Pages. Newer, is certainly not better with Pages v5.

  • Cannot Print pdf document

    A user on windows Vista is unable to print any pdf document. All other documents print to the printer. However, when pdf document is to be printed, it prompts for "Save As'.  I have upgraded the version from Adobe reader 9 to 9.4.6 to version 10.  No improvement. I checked for updates, still the same problem.  I uninstalled and reinstalled Adobe reader.  Same problem.  I gave user full rights to the Adobe folder under Programs folder.  Same problem.  However, when i log on as Administrator, I am able to print.  However if they are given temporary Admin rights, they still cannot print.  Would like to know if any one else has come across this and if so what the fix is.  Thanks.

    Generally that means that the "print to file" box is selected in the print dialog menu. If so, deselect it and this will stop.

  • Cannot print Word documents

    Hi - been having this problem for as long as I can recall! Occasionally I can get a document to print - I managed 2 days ago, but went to print off some word docs today and get the message 'word cannot print, there is no printer installed'
    Yet when I go to 'devices and printers' the printer is there - with a great big green tick - the laptop also 'bongs' when I plug in the USB lead -meaning the printer has been found.
    Various things i have tried:
    I uninstalled the printer, then re-installed it again.
    I tried it in a different USB slot
    I turned the printer off and on again
    Printer works fine on my desktop PC
    Any wise words before I succome to temptation and chuck it against a wall lol!

    Hey,
    Can you use your printer with other programs? For example can you print a pdf file or some Excel sheets?
    Furthermore I cannot read any information about your operating system, notebook model, printer, etc. and these information are necessary.

  • Cannot print all documents in a Portfolio

    Using Acrobat 9.1 for Windows the "All documents in portfolio" option in the print dialog (which online help suggests to use) is simply not present. Any idea why this is?
    So I have to keep printing all documents individualy which is a pain obviously.
    Thanks for any help
    mwfn1

    I am having the same problem using Adobe Acrobat Pro on Windows XP SP3, but none of the suggestions have worked.
    No matter what layout I choose, with no files selected, all files selected, or only a few files selected, the only "Print Range" I get in the print dialog box are the standard choices of All; Current view; Current Page (greyed out); and Pages (greyed out).  I simply can not get the choices of "All PDF Files" and/or "Selected PDF Files" to appear under the Print Range.
    I have tried:
    Selecting and saving the various layouts without previews;
    Creating brand new portfolios wihin Professional 9.3.3;
    Selecting differenct printer drivers; and
    Performing a complete uninstall and reinstall and update to 9.3.3.
    No matter what I do, I can not get "All PDF Files" and "Selected PDF Files" under the Print Range to appear.
    This problem does not appear on other machines opening the same portfolio (opening the same portfolio on other machines I get the "All PDF Files" and "Selected PDF Files" under the Print Range).  It only appears to be a problem on my laptop, which is a big problem as it is my only machine.
    Any ideas?

  • Cannot print complete document

    Setup:
    PC1
    Windows XP
    Adobe XI
    Xerox WC 6400
    Server 2003 - Print server
    PC2
    Windows 7
    Adobe X
    Xerox Phaser 8560MFP
    Server 2003 - Print server (different)
    Problem:
    Initial problem was printing any page after first off centered. We corrected that problem by choosing "print as image." PC1 and PC2
    Second problem was printing more than 4 pages. 23-page document would only print 4 pages. Windows would only show 4 pages in the spooler, but I could see Reader XI was still compiling the document. PC1 only.
    What I've done:
    I was able to duplicate the first issue on PC2. I was NOT able to reproduce the second issue. I had no trouble at all printing the full document in one go. This document is the smallest document printed to go into a report, and all of the other documents print without issue on PC1.
    Question:
    Since I'm sure Microsoft would say that Adobe Reader is the problem, and Adobe would say Windows is the problem, I'm asking here, hoping for a neutral opinion. I can't tell if the problem is the PDF (since it did print correctly somewhere else), the print server (since it does print larger documents), or the PC (since it was able to send the correct information to the same printer through the same server for other PDFs).

    Save it as a pdf and then try printing it.

  • I have Reader XI. All of a sudden I cannot print a document in Reader.

    I have Reader XI. I have a HP laptop with Windows 7 and a HP Envy 5530 printer. I was able to print from Reader last week. Now all of a sudden I cannot print. Not having printer issues except with Adobe Reader. Tried the suggestion to change security level in Reader. That did not work.

    I found this on the Adobe site.  Seems to be working for me...for now.  Needs to be set as Administrator and it works fine after that. Not sure why mine switched unless it was during some type of update.  Good Luck!!!
    http://http://helpx.adobe.com/x-productkb/global/run-program-administr ator-windows-7.htmlhttp://

  • I cannot print pdf documents from Adobe Acrobat

    When I open up a pdf document in Adobe Acrobat, I am unable to print it. If I try and use an HP Laserjet 1606 laser printer Acrobat crashes. When I use either an HP Office Jet 7000 wide format ink jetprinter or a Brother MFC 3360C multi function ink jet printer I either get an error message that says "This document cannot be printed" or Acrobat crashes.
    I can print using the Preview program.
    Any suggestions?

    Jim1848 wrote:
    Any suggestions?
    Try the Adobe forums as it's their software you're having problems with:  http://www.adobeforums.com

  • Cannot print PDF documents

    Hello:
    I get "The document cannot be printed" and then followed by "There were no pages selected to print", but I did select pages to print. 
    How to fix this?

    Try disabling Protected Mode [Edit | Preferences | Security (Enhanced)].

  • Cannot Print - "My Document" folder opens to save the page as a TIFF

    Windows XP SP
    Firefox: 3.6.3
    For no apparent reason, when I want to print a Web page (whether or not there are images, it opens the "save as" dialogue box and the TIFF option is checked (there are no other optons). If I save it "Microsoft Office Picture Manager opens" and if I want to print the "Print Wizard" opens.
    I can print .pdf files.
    I can print from internet explorer.
    Finally I cannot access the "reset" link on this Web site. (it states "timed out".
    The last update was in April (security update).

    Yesterday I suddenly developed a similar problem. If I opened FILE>PRINT it only offered "save to Microsoft XPS Document Writer" and if I clicked "save" I just got an error popup. When I opened "Print" on the Navigation Toolbar the Printer Name was shown as the XPS Document Writer. However the dropdown arrow produced a list including hp 5500 series which is my printer and when I changed the name all was back to normal. I have no idea how the name got changed to the XPS Document writer. No-one else uses the computer and I never use the Navigation Toolbar print instruction; I always use File>Print. Could it happen as part of a Firefox update?

  • I have the same problem with printing as by laurieb13019.  Have tried everything and still cannot print a document.

    I have tried everything to print a .PDF document in Adobe Reader and cannot.  It is printable with another .PDF software but not with Adobe Reader.

    You cannot attach files or screenshot in email replies; it won't make it into the forums.
    How to share a document with the forum:
    https://forums.adobe.com/thread/1408375
    How to post a screenshot:
    https://forums.adobe.com/thread/1070933

  • Cannot print PO document from ME9F

    Dear Expert,
    Hi, I got trouble when printing out the PO document. Here, I have created new PO type (PO Mold) with series number 457xxxxx
    but the problem is i cant print out the PO 457xxxxx from ME9F. there is a message : no suitable purchasing documents found.
    but it's possible to print out manually from ME22N.
    maybe any settings i have missed out when creating the new PO type that lead to error when printing in ME9F?
    any suggestion where should I check?
    Thanks
    Pauline

    Dear Expert,
    I have set the condition record in MN05 , but the document still not appear in ME9F
    Processing status 1 is for the showing the document that has been printed. for the document thas has not been print yet i use processing status 0 , but the message "no purchasing document can be found" appear.
    What should I do then??
    I need advice..
    Thanks
    Pauline

  • Print out size lost control after upgrade to osx 10.9, cannot print 100% document original size, why?

    As subject said.
    I'm using Xerox 1450GA, before upgrade to OSX 10.9, printing Adobe file could be in 100% real size. After upgrade, lost control, even checked setting in 100% in setting, come out image still auto reduce few percents, that make me confuse and cannot complete digital printing jobs, someone have same problem?  Please help to solve...

    I've spent hours on the phone going in circles with HP's "support" (I use the term loosely here) and can confirm that it's a driver issue. The best part is, HP and Apple claim that neither of them have a copy of the v2.14 driver that actually worked, and I can't seem to dig one up online anywhere. I've tried everything under the sun and just gave up... ordering an Epson and selling both of my HP's. I think the only other option is to wait for HP to release working drivers, but since they don't even seem to understand that their driver is the source of the problem, I wouldn't hold my breath.
    It seems really crazy to me that neither the manufacturer nor Apple keep a copy of the previous driver, but that's what I've been told. HP did release what they're calling a new 10.9 raster driver (available on their site), but it didn't fix the problem for me. If you have a timemachine backup from before the 2.16.1 driver was released, I'd restore to that and turn off automatic updates. If you don't (like me) seems like your stuck.

Maybe you are looking for

  • How do I apply a style to a hyperlink?

    Help! How do I get rid of the default underline, and colours 'link:blue, visited:purple, active: red, hover:blue' for all hyperlinks in my site? And is it possible to create a specific style for all links? if so, where do i do this...in the CSS? Many

  • How do i switch ipod/itunes account to new computer

    how doi switch my ipod and itunes account to a new computer

  • Songs not shown up in Nokia 5800 after transfer an...

    Hello, I've been trying unsuccessfully to add songs to my new 5800. I'm a Mac user and had,therefore,downloaded Nokia Multimedia Transfer for this purpose. I had NMT up and running and connected my mobile with the usb cable provided with the phone. I

  • Display dark after bootcamp?

    After I installed the Apple support drivers the screen display was dark, I downloaded the latest nvydia drivers and the screen display is what you would expect, trouble is when I reboot the display goes dark again. Its almost like the updates are rev

  • Need a basic command in sql pls...

    HI all, I am beginner in sql, when i write the query like this "select * from tab;" this query brings all unwanted tables,i just want to see only my tables which i have created pls some one tell me.I showed below how it look likes. Thanking u all. SQ