BufferedReader won't read.

Got a simple program that checks if the file "adressbok.txt" contains any text.
If it does, the program reads that text and writes it again and also writes a new String indata.
The problem is that my program gets stuck in the while-loop. I suppose the break-code kicks in but I don't understand why? I've specified that the code should break only if the nextline equals null.
My Question: How do I modify the code below so that the program DOESN'T go to break automatically. What am I missing here?
The specific code is:
BufferedReader    inFil = new BufferedReader (new FileReader ("Adressbok.txt"));
PrintWriter    utFil = new PrintWriter (new BufferedWriter (new FileWriter ("Adressbok.txt")));
while (true)
     String    rad = inFil.readLine ();
     if (rad == null)
          break;
     utFil.println (rad);
String indata = "test";
utFil.write (indata);

I wan't the program to add a new contact to the file adressbok.txt. The program asks for a name and an adress and then writes it to the txt-file.
However, I want it to add that person at the bottom of the file. (I don't care about alphabetical order just yet). Also, I want to do this without using RandomAccessFile.
If I use FileWriter it simply erases the previous content of the txt-file. Therefor I created the while-loop so that the program could:
1. Read the previous content of the txt
2. Write it again
3. break when there is no more to read from
4. "jump out" of the loop and continue writing the new information.

Similar Messages

  • DVD drive won't read disks at boot

    I have a Paviliton DV6-2113sa running Win7 HP  64bit. 
    I removed Acronis True Image and when I rebooted I got a BSOD at the point when the coloured balls should merge into one.
    I thought OK, put the system repair disk into the DVD drive and boot up, but the drive is failing to read any recovery dosks. I think the drive has packed up as I haven't used it for some time.
    Can I use any replacement drive in this model or must I get the same one again?
    The drive light flickers as though it is reading data but it doesn't 'spool up' to speed and I don't get the 'press any key to load from DVD'.
    The BSODs are a seperate issue which I think running a system repair will fix but I can't as the drive won't read data.
    Is it possible to put the repair disk files onto a 4gb USB stick and if so, how do I do it?
    Thanks.

    Hi Peeps
    I had exactly the same problem with my Macbook, again from the UK. Really weird though as would intermittantly read DVD film's which worked fine previously.
    Well.... Took it to my local Apple store and saw a genius and anyway they replaced the super drive and logic board (surprised about the logic board!).
    But just got it back today and the DVD drive is completely fubard so is being returned tomorrow to get this sorted!
    Moral of the story, sounds like a drive or board problem. Will keep you updated when I get mine back
    Macbook 2Ghz, 512Mb, 60Gb, Superdrive   Mac OS X (10.4.7)  

  • Hp pavilion dv4-1123us Media Card won't read

    I have a hp Pavilion dv4-1123us laptop that won't read a 16 GB SDHC media card. The card works in my PC, so the card is good. I have a Scandisk 5-1 media reader hooked to my home PC that would not read it but I found through Scandisk site I needed to download the latest Firmware which I did and now the card works on my PC. The reader has always and still does read a 512 MB and a 2 GB XD cards on my laptop. I am running XP Pro OS.
    I have searched the HP site for driver downloads but only see them for Windows 7 and 8 not XP.
    Can someone help me on this?

    Hello wgray826,
    You’re having a problem not being able to read a 16GB SDHC card.
    I think that your computer does not support the SDHC card.
    Here is a link to your user guide and what cards it supports.
    I noticed that it shows the Secure Digital but not the Secure Digital High Capacity.
    Clicking the White Kudos star on the left is a way to say Thanks!
    Let me know how everything goes.
    Have a good day.

  • How do I set up an external MIDI input on the new MacBook Pro? Mine won't read it.

    I've been trying to set up my TASCAM US-600 on my new MacBook. I've never used a Mac before so I'm not sure what's wrong. I tried installing the drivers and when I plugged in the interface, it wouldn't read the device. I now have the interface plugged in through a USB hub. The Mac now reads TASCAM software but when I go to the system preferences, the Mac won't read the MIDI input. So all in all it's been a big pain in the ***. Are there any Mac experts that may know what the problem is or how to help? Thanks!

    are you sure its mini display port? MDP and thunderbolt are the same port.
    for referenece, this is mini DVI (obsolete)
    Kobushi-mini-dvi.jpg
    This is mini display port
    Mini_displayport.jpg

  • Palm Desktop 6.2 won't read data file after IR synch with IIIC

    I have Windows 7, an old IIIC, and Palm Desktop 6.2. Since I can use a USB with that combination, I synced with an infrared connection. The files made it to the Palm directory, but the desktop program won't read them. My previous version of Palm Desktop allowed me to search for the data directory, but I can't find a way to do so with 6.2. And, no, the older version wouldn't display the data, either, in spite of my specifying the path.
    I'm so close! One more step and I won't have to buy a smart phone and pay a monthly fee to carry around my contact date. Please help.

    Palm Desktop 6.2.2 is not an upgrade to 4.x!   It was designed to fix the things Microsoft broke when Vista was born.
    It lacks many features that existed for many years in the 4.x versions.
    I'd suggest doing a Clean Uninstall and reinstall your original version!
    http://forums.palm.com/t5/Windows-HotSync/Instructions-for-a-Clean-Uninstall-of-Palm-Desktop-on-Wind...
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • ITunes won't read ID3 tags that Windows sees

    I recently switched my library over from a Mac laptop to a PC desktop. I have about 70 GB of perfectly organized music accumulated over years and years.
    In the process, after I loaded some songs into iTunes (using the Keep My iTunes Folder Organized and all that stuff), I noticed that about 10 GB of music were without titles, artists, or album info, and just displayed the name of the MP3 file (so like instead of displaying 15 Step by Radiohead from In Rainbows, Track 1 it displayed "01 15 Step" in the Title column only).
    The problem is that when I navigate to these songs in Windows Explorer, not only do I see all of the correct ID3 information, I see the extras like Album Art have loaded perfectly as well. I can play these songs in Windows Media Player and the ID3 info is perfect.
    Does anyone know why iTunes won't read these ID3 tags or how to get iTunes to read them?

    I am also having the same problem with about 200 of my MP3s. The tag info shows up perfectly using QuickLook on Leopard, but in iTunes I can't see any of the info. I have tried converting the ID3 tag version, revesing the unicode....nothing.
    Have you had any luck?

  • CD/DVD drive won't read any CDs or DVDs

    Whenever I insert a DVD, CD, or CD-ROM my computer won't read the disc. The computer starts making noise like it is reading the disc but then it stops. It tries 3 times (starts and stops) and then just spits the disc out. I can't watch movies, install software, etc. How do I fix this.

    Before taking it or sending it anywhere I'd first try resetting PRAM…
    http://docs.info.apple.com/article.html?artnum=2238

  • Drive won't read any dvd ejects it automatically

    My drive Won't read any kind of DVDs, it keeps ejecting automatically after spinning for a while. it's been going on for a while now. please help!!!!!

    You can try resetting the SMC Intel-based Macs: Resetting the System Management Controller (SMC) - Apple Support
    and PRAM How to Reset NVRAM on your Mac - Apple Support
    If that doesn't help you can try a cleaning disc or a quick shot of canned air. It's likely though that your drive has failed, it' not all that uncommon. It that is the case you can either replace it or have it replaced but it's far cheaper just to buy a usb external drive....just not Apples because it won't work with macs with a built in drive working or not. .

  • Pavilion DV4-2161nr CD/DVD drive won't read or burn

    I recently had my Hard Drive changed in my HP and the CD/DVD drive was working fine...then about a month ago the door won't open and it stopped reading every cd/dvd i put in...it won't read blanks or movies or audio cds/dvds...I also have a yellow question marke by PCI Device...CAN SOMEONE PLEASE HELP ME?

    do you have the win 7 cd handy, try to boot into the discs and see whether that works, this will tell you whether that is software or hardware problem. Such failures do occur, due to ageing of laser. 
    Regards,
    Jin Li
    May this year, be the year of 'DO'!
    I am a volunteer, and not a paid staff of Lenovo or Microsoft

  • Hp pavilion cd/DVD drive won't read discs

    My pavilion G6 G6 2295sa won't read cd/DVD but will play DVDs with cyber link I have gone through the suggested routes when I put in the error code E:\hp DVD-RAM UJ8D1 H.01 please help.

    Hi Primhak,
    Welcome to the HP Forums! I need to clarify a couple of things the optical drive (CD/DVD drive) is playing DVDs but won't CDs is that correct? What is this error code that you are talking about? What operating system are you running?
    Finding your OS:
    http://windows.microsoft.com/en-CA/windows/which-o​perating-system
    Thank you,
    Please click “Accept as Solution ” if you feel my post solved your issue.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Thank you,
    BHK6
    I work on behalf of HP

  • MacBook CD/DVD drive won't read disc

    I have a Apple MacBook MC207LL. I have run into a major problem. My CD/DVD drive won't recogonize a disc when it's inserted (I have to force eject it). Disk utility shows that there is a disc present in the CD/DVD drive.
    My major issue is that I erased my partition so I can have a clean install of my laptop. Now I can't reinstall the OS because it won't read the disc or a USB.
    Is there a way to use Terminal to force it to read my data on the disc?
    Otherwise I am stuck with an empty computer that I will never be able to use I have done research on this and nobody has run into this exact problem as me. If someone can take their time to help me out that would be greatly appreciated.

    I am having the same problem, but now mine wont even notice that the disc is there! I wouldsay take it to the genius bar.

  • HT1338 DVD drive won't read or burn

    DVD drive won't read after upgrade to mountain lion install

    do you have the win 7 cd handy, try to boot into the discs and see whether that works, this will tell you whether that is software or hardware problem. Such failures do occur, due to ageing of laser. 
    Regards,
    Jin Li
    May this year, be the year of 'DO'!
    I am a volunteer, and not a paid staff of Lenovo or Microsoft

  • DVD Drive Won't Read "Homemade" Data Discs

    Hello! I just purchased a T500 with a regular old DVD burner (Optiarc DVD RW AD-7910S) and am having an issue with it. The problem is that it will read certain DVDs just fine (a Visual Studio DVD, for instance, worked just fine. As did a Vista Ultimate DVD). Unfortunately, other discs are not so fortunate. Anything that contains just plain old data files (such as a disc of log files, a disc with video files, etc) won't load at all. The drive will spin up, spin down, make a floppy disk reading clunking sound, and repeat the procedure.
    So it seems that anything that comes from an ISO or an "official" source (Microsoft) works fine, but any time a disc was burned with Nero or the Windows burning thing(tm) it won't read at all. This doesn't apply to CDs, however, which seem to be working just fine.
    Is this an easily fixable problem? Could it be a problem with the hardware? It doesn't seem like that would only stop it from reading data discs, but I'm no expert. I updated the firmware to the latest version available on the download site (actually I did that before trying any data discs, so I don't know if it was an issue with the old firmware). Is it possible that it didn't update properly or something? Would it be worth trying (or possible) to redo the firmware update or to revert to the old version to test? Forgive me if I'm sounding ignorant here.
    Thanks for any insights!
    P.S. I'm using Windows Vista Ultimate 64-bit, if that makes any difference to anything.

    Total WAG:  are your home-made data DVDs finalized?  I think just about everything these days can handle mulit-session CDs, but IIRC there are some configurations that won't recognize multi-session DVDs.
    Like I said, just a WAG.
    Z.
    Message Edited by zoltanthegypsy on 04-19-2009 05:05 PM
    Message Edited by zoltanthegypsy on 04-20-2009 09:52 AM
    The large print: please read the Community Participation Rules before posting. Include as much information as possible: model, machine type, operating system, and a descriptive subject line. Do not include personal information: serial number, telephone number, email address, etc.  The fine print: I do not work for, nor do I speak for Lenovo. Unsolicited private messages will be ignored. ... GeezBlog
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

  • MBP/iBook won't read repaired USB drive?

    I have an ativa thumb drive I've been using for a few months now. In the past few days suddenly my MBP (also an iBook) gives me the message "Disk you've inserted cannot be read by this computer - Initialize / Ignore / Eject."
    So I opened Disk Utilities and ran 'repair disk' and it said minor repair was needed to the header. Ran repair disk it says disk is repaired. Run verify disk and it stops saying the header needs minor repair. Run repair disk, it says disk is repaired. Computer still won't read it.
    I boot up from my startup disk and again open Disk Utilities from there. Run Verify Disk and Repair Disk and both say no repairs are needed? For grins I checked my HD and a minor problem was found so I ran repair disk on it. Disk Repaired. I've rechecked both drives nultiple times and each time the reslt is no repair required.
    I launch from my on board system (i.e. without startup disk) and again computer says disk can't be read - initialize / ignore / erase? In fact I get 5 windows with that same message in rapid file on my screen.
    Any idea what gives? If both drives are OK - why won't it read the info as before???

    See KB Articles: 
    http://support.apple.com/kb/HT1411 Apple Portables: Resetting the System Management Controller (SMC)
    http://docs.info.apple.com/article.html?artnum=2238 Resetting your Mac's PRAM and NVRAM

  • I updated my iPhone 4S and now my iTunes (10.6.1) won't read it. It said to update, but 10.7 won't work on my computer because it's a Mac 10.8. I can't find the iTunes 10.6.3 anywhere. What can I do to be able to sync my computer and phone?

    I updated my iPhone 4S and now my iTunes (10.6.1) won't read it. It said to update, but 10.7 won't work on my computer because it's a Mac 10.8. I can't find the iTunes 10.6.3 anywhere. What can I do to be able to sync my computer and phone?

    iTunes 10.7 does indeed work on OS X 10.8 Mountain Lion. Do you mean you have Mac OS X 10.5.8 Leopard? If so, and you updated your iPhone 4S to iOS 6 on some other computer, then you may be out of luck synching to your 10.5.8 system, but you can get and try 10.6.3 here:
    http://support.apple.com/kb/DL1575
    Regards.

Maybe you are looking for