Reading in only half the file

Using this code I am only reading in Half the file:
BufferedReader in = new BufferedReader(new FileReader(inputArg));
while(in.readLine() != null) {
String record = in.readLine().toLowerCase().trim();
c2 ++;
System.out.println(c2 + record);
But when I use this code I get everything:
FileInputStream fstream = new FileInputStream(inputArg);
DataInputStream in = new DataInputStream(
new FileInputStream(inputArg));
while (in.available() != 0) {
String record = in.readLine().toLowerCase().trim();
c2 ++;
System.out.println(c2 + record);
I would like to use the top code because I was told to stop using the DataInputStream class.Hopefully someone can let me know what I am doing wrong up top.
          

Your code is only reading every other line.
while(in.readLine() != null) { //here you read a line and check it is not null
String record = in.readLine().toLowerCase().trim(); //here you read the next line and process itWhat you need to do is read the line only once. Therefore, read the first line before the loop into a string, and reference that string in the loop. e.g.
String line = in.readLine();
while (line != null) {
  // do stuff with 'line'
  // at the END of the loop, read the next line ready for the next stage of the loop
  line = in.readLine();

Similar Messages

  • Superdrive only reads half the files on a DVD

    I am running Mac OS X v10.3.9 on a 1.25 ghz G4 iMac.
    I got a commercially produced data DVD for Christmas. I don't know if it is dual layer or what, but it contains 5.35 GB of mostly acrobat files.
    I can read and/or copy about half the files on the disk, the other half of them error out or lock up the finder when I try to copy and when I just try to read/open them the ball spins for a long time then just stops without opening anything.
    All the files open without difficulty on the Windows PC at work.
    Is this weird or what?
    I rebuilt my permissions and no improvement. Any ideas what else I should try?
    Thanks!!

    Could the disc(s) in question have been burned using a utility that allowed
    multiple sessions; and not been set to be used in both Mac and PC?
    Some can do that and not be recognized. Third party disc burning utilities
    can also add files to burned CD-RW or DVD/RW discs; but they may not
    all be seen by the different optical drives and/or software in other systems.

  • When I try open a .pdf file my Adobe Reader 11 only allows the download / save opening the related window and don't show me both options 1) open with ... and 2) save as.... probably someone flagged the choise... always perform this way ....

    When I try open a .pdf file my Adobe Reader 11 only allows the download / save opening the related window and don't show me both options 1) open with ... and 2) save as.... probably someone flagged the choise... always perform this way ....
    Could some one give help and let me know where I can probably find the settings option that allows me to change and switch to previous situation where it was possible to decide time to time how to proceed either opening the file or saving it ??
    Thanks in advance
    David

    What is your operating system?
    Open a PDF from where?  If online, in what browser?

  • How do I stop pop up that asks me, Do you want to save changes to doc... before closing? I have made no changes only printed the file. Using Adobe Reader DC, Windows 7 64 bit.

    How do I stop pop up that asks me, Do you want to save changes to doc... before closing? I have made no changes only printed the file. Using Adobe Reader DC, Windows 7 64 bit.
    This is very annoying and we need this stopped as we have made no changes to any of the adobe files. Please advise how to do this.
    Customer Service DCC

    I first tried the version without the deflated stream (so everything uncompressed) against the online repair tool to check/analyse it @ https://www.pdf-tools.com/osa/repair.aspx
    And it says no error found, but the reader still want to save it when closing so i still had no clue at this point.
    Fortunately, i finally found what was wrong with my generated PDF.
    In my xref table, each object reference was not end by a full EOL, i only did put a newline char.
    Now i have "carriage return" "newline" which is the full EOL and the reader is happy and close the file silently.
    As suspected i did not follow correctly the specs on xref table
    Now i'll go and figure what i did wrong with the deflate filter
    Thanks for your help.

  • Can't save the illustration.  The file may be read only, or the file is in use by another applicatio

    Getting error "Can't save the illustration.  The file may be read only, or the file is in use by another application."  The file is not read only and is not in use by another application.

    The same thing may happen in Windows Explorer, specifically if it is a very big file (physical size), so preparing the preview may take a lot of time.
    In that case it is used by "another application", that is: Explorer.
    By the way, which version of Illustrator are you using, Tetons?

  • I have a document that I wrote today on my phone, went to open it again and the app kept crashing or it would only open half the file. Is anyone else having this issue? On the preview it shoes the whole file, but when I open it only shows a few paragraphs

    I have a document that I wrote today on my phone, went to open it again and the app kept crashing or it would only open half the file. Is anyone else having this issue? On the preview it shoes the whole file, but when I open it only shows a few paragraphs. When I email the file it only shows a few paragraphs, but when I go to open it both on my ipad and iphone it crashes the app.
    Everything is up to date.

    I also have Jolly's problem. I found the iMovie 9.0.9 folder and tried to launch the older version of iMove. It would not launch. I removed all of the iMovie preferences from the Preferences folder, removed iMove 10 from the applications folder, and restarted my Mac. iMove 9.0.9 still won't launch and I can't access my videos created with the older version of iMovie. Is there a way to uninstall iMovie 10 and reinstall iMovie 9.0.9?
    I am running Yosemitie on a  iMac.
    Paul

  • Only half the cores/processors being used in bootcamp?

    I have two mac pro computers that are both running bootcamp with Win 7 and both are giving me the same problem. One mac pro was purchased in 2011 and the other is early 2008.
    When I run Cinibench on both these machines I find that only half the cores and processors are being used, more than doubling the render time for the same scenes run in OS X 10.6
    I followed all the online installation guides and have had few problems with running all the programmes I use apart from Studio Max.  Studio Max runs perfectly well on these computers but like I say only uses half the processing power that should be available.
    Does anyone have any suggestions for where I might have gone wrong with the installation or what I can do to rectify this problem.  Any suggestions would be most welcome
    Thanks in advance

    Steven Poleske wrote:
    I might be wrong, very wrong but I believe you might be able to upgrade from within Windows7. Look for the Anytime Upgrade and you might be able to buy and install within the Win 7 environment.
    You are wrong:
    Read this (from Microsoft)
    If you want to move from a 32-bit version of Windows to a 64-bit version of Windows 7 or vice versa, you'll need to back up your files and choose the Custom option during Windows 7 installation. Then, you'll need to restore your files and reinstall your programs. For more information about performing a custom installation, see Installing and reinstalling Windows 7.

  • I edited a movie on iMovie but when i try to upload it to youtube only half the video shows ( its only 3 minutes long) does it need converted? help?????

    i edited a movie on iMovie but when i try to upload it to youtube only half the video shows ( its only 3 minutes long) does it need converted? help?????

    I have the same issue.  If you are exporting from iMovie version 10.0.1, I run into the same issues if I export directly to YouTube or if I export to file then upload to YouTube.
    Google's help file doesn't properly address this problem and thier help is also out of date.  In talking to a support rep at Apple, they said the export to YouTube should just work or the exporting to a file then uploading otherwise it's an issue for Google support.
    If someone can post a solution that works (is a streamable format - which is different than the format that YouTube accepts as it will accept many formats but take a long time to process them), I'd be interested to hear also.
    Thanks,
    Rob.

  • Why is only half the page printing

    i have a Deskjet f380 when i want to print a page, the preview shows only half the page. and it will only print half the page. i checked the setting and they seem to be fine, what gives?

    Suddenly my HP J5780 printer releases pages that gradually lose printing -- top of the page OK, middle weak, no bottom. What to do?

  • HT2506 I am trying to convert  word document to a PDF but only half the document accurately converts. Is there a way to fix this?

    I am trying to convert  word document to a PDF but only half the document accurately converts. Is there a way to fix this?

    I have found that complicated document structures causes Word to split the document into parts, but I've always gotten the whole thing, in multiple documents.
    However, with two pages, I can't imagine it is that complicated.
    Any odd fonts or paragraph styles?

  • I purchased an album but only half the songs will download. How do I get the other half to download?

    I purchased an album but only half the songs will download. How do I get the other half to download?

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copy of the track and try redownloading a fresh one.
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the entry, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.
    (Not entirely sure what happens after you click that link, but fingers crossed it should be relatively straightforward.)

  • Saving report in Report Builder 10.1.2. saves only half of file

    Hi,
    I have problems with saving files in Report Builder 10.1.2. After saving a rdf-file it shows only half the size of the original file.
    When closing the report in Builder and opening it again it won't open. Also the temp-file is half the size of the original rdf-file during saving.
    Can someone help me to solve this? Auto-save in Preferences is turned off. Have tried to open and save files on the network and on the local pc.

    Hi,
    Did you used OUTER join?? if you have any suitable Outer join according to my understanding query should return Assignment data but with NULL value, then you can replace as you need it in Reports.
    Regards,
    Syed

  • Every time I use safari on my macbook pro with retina display, only half the page will load then it freezes up?

    Every time I use safari on my macbook pro with retina display, only half the page will load then it freezes up? It's brand new, so I don't understand why it would be doing this?

    The warranty entitles you to complimentary phone support for the first 90 days of ownership.

  • A purchased song did copy complete. Only half the song plays

    A purchased song did copy complete. Only half the song plays

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copy of the track and try redownloading a fresh one. See the following document for instructions:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the item, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.

  • Sender file communication channel polling only when the file is written

    Hi guys,
    I have the following scenario:
    I have developed an XI interface that takes a .txt file from SAP R/3's file system, usr/sap/trans/ and delivers it into another ftp location. The problem that we face is that the file is written into source directory from an ABAP program. As a result, XI go and polls into source directory when the file is not completely written, or when it is empty, which blocks the process.
    Is there a way to force XI in order to poll the source directory only when the file is complete?
    We have thought of exporting the file into a name that XI does not expect and as soon as the file is complete to rename the file from inside ABAP program into what XI expects.
    However, the command inside ABAP changed the Code page of the file and we cannot see some special characters in the file that is delivered to the ftp location.
    Any ideas??

    Hi Evaggelos,
    from <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm">SAP help: Configuring the Sender File/FTP Adapter</a>:
    Advanced Mode
    To specify additional parameters in the adapter configuration, set the Advanced Mode indicator.
    &#9679;      Msecs to Wait Before Modification Check
    Enter the number of milliseconds that the adapter must wait before it checks whether the files have been changed
    Regards,
    Udo

Maybe you are looking for

  • Loading contacts on my new BB Curve

    I am unable to get my BB Curve to give me an option to import list of 530 contacts over. How am I supposed to transfer contacts? Help please!

  • 3rd party sat nav for e51

    i am looking for a 3rd party sat nav that is compatible with my e51, i understand that i need an external receiver but am not sure which one would be the best for my phone? ideally the mapping of the sat nav would be topographical as well as street m

  • 2400MP display in black and white

    Can someone help me out,  Just last week my project only displays in black and white. I have gone through evey setting I can find but don't know what the issue is.

  • Interactive activity with multiple business rule transitions

    I use BPM standalone and studio 10g. I create two business rules. Business rule 1: amount greater than 100. Business rule 2: amount greater than 300. An interactive activity has two business rule transitions and an unconditional transition. This acti

  • GPU acceleration for command line renderer?

    Hello, is it possible to use CUDA for batch rendering with many projects over the command line tool aerender ? Would a nVidia TESLA GPU significantly increase the performance? Or are only the 570/580 and Quadro GPUs supported? kind regards Poison Nuk