Reading lines and then comparing them

Hi,
I want to read two lines of a single file and then compare them. Right now, I've implemented:
String line = null;
String currentLine = null;
String prevLine = null;
BufferedReader bf = new BufferedReader(new FileReader(fileA));
while ((line=bf.readLine()) != null)
            currentLine = line;
            prevLine = line;
        }I understand that this code returns the same line, but I was just hoping that maybe someone could point me in the right direction. Thanks in advance.

800343 wrote:
remember to use .equals() for equality comparisons. For comparing objects' states (contents), yes, absolutely. That's what it's for.
The == tends to act funny, even in situations where it should obviously work.No it doesn't. It works exactly as it's supposed to. It compares the value on the left side to the value on the right side. Always. Whether those values are primitives or references, it behaves the same way.

Similar Messages

  • If I delete my songs from my "Downloads" folder, have them in my "Trash" and then delete them from my "Trash", will I still be able to play the songs on my iTunes or will they be deleted on my iTunes as well?

    I want to clear some space on my Mac since it is filling up and I don't have much room left on it. I want to delete all my songs from my "Downloads" folder and then delete them from my "Trash" to free up space however, I'm worried that if I do this then iTunes will not play any of the songs I deleted.
    Will I still be able to play my songs on iTunes even if they are not in my "Downloads" or "Trash" folders?
    Thank you.

    All tracks in iTunes (if you use default settings) should be in various artist and album folders in the main media folder in the iTunes folder. You can right click a track to reveal its location in Finder.  If there's a copy there then it doesn't really matter what you do with other copies.
    I have never downloaded from iTunes but I thought it placed files directly in the correct locations, or is this some other downloads folder to which you are referring?
    Normally if you download a file from another source and add it to iTunes by dragging it there, or using the Add To menu item, it places a copy of the file in iTunes.  You can discard the original, but if you're concerned you can check which copy iTunes is actually using as above.

  • HT1386 Because of limited internet on my iphone 5, i download updates to apps thru ITunes and then sync them to my iphone.  Lately, the apps download properly and the sync seems to go thru, but on my phone, they keep saying they are updating and it never

    Because I have limited internet package on my att iphone 5, I update apps on my computer thru ITunes and then sync them to my phone.  The downloads seems to go thru and then install.  But when I turn on my phone, the affected apps continue to say they are updating and it never goes away.  I do not have wifi but when I am connected, the apps don't update.  Help!!!!

    Oh my gosh I had the EXACT same problem, and for ages I couldn't figure out how to fix it until today. Here's what I did:
    First I went onto my computer, opened itunes, and un-installed tumblr, vine and kik. These were the apps I was having problems with (it said I had them on my phone but, like you, they didn't show).
    Then I went to the itunes store, searched for each one, and it said I could update them so I did (just FYI: for tumblr a window popped up saying "please click ok to confirm you are 17 years or older", so I did that also)
    When I went back to my phone and tried installing them again (still on my computer), it worked!
    I hope this helps, because it was incredibly frustrating. Good luck!

  • Before I upgraded to 8.0 I could double click and see all open Apps and then close them. Now when I double click I am not sure what I am seeing or what to do?

    Before I upgraded to 8.0 I could double click and see all open Apps and then close them. Now when I double click I am not sure what I am seeing or what to do?

    The format keeps changing but the basics remain...in the center of the screen are large images of the recent apps which you can close by swiping up and away.

  • How can I move all my bookmarks from different Firefox profiles into one area to organize them and then place them into the different Firefox profiles?

    How can I move all my bookmarks from different Firefox profiles (would like to move whole bookmark folders at once if possible) into one area to organize them and then place them into the different Firefox profiles? This is all under one window user account, I am using windows 8.1. Even if you have information on how to do it on a different windows, it may still be helpful. Thanks for any input you have.

    Just a note about the difference between these two things:
    * "export" and "import" use an ancient HTML document format that all browsers can understand. When you import bookmarks, Firefox may place them into an Imported Bookmarks folder, or into Unsorted Bookmarks. This does not displace existing bookmarks, and Firefox does not automatically remove duplicates.
    * "backup" and "restore" use a more comprehensive JSON data file, which contains extra information about your bookmarks (such as tags) not contained in the traditional export file. HOWEVER, a restore completely replaces all existing bookmarks, so the restore feature cannot be used to merge in a set of additional bookmarks.
    Related support articles:
    * [[Export Firefox bookmarks to an HTML file to back up or transfer bookmarks]]
    * [[Import Bookmarks from a HTML file]]
    * [[Restore bookmarks from backup or move them to another computer]]
    Some users find the disk-based Windows Favorites folder a convenient way to organize bookmarks. If you do, too, and you do not need to preserve tags on your bookmarks, you could export each profile's bookmarks to HTML and import them all into IE11. Organize them in the Windows Favorites folder, then export from IE11 to HTML and import that file into each Firefox profile. See: [http://windows.microsoft.com/en-us/internet-explorer/add-view-organize-favorites].

  • I use version 4.01. How do I backup bookmarks and then import them into my laptop?

    I want to export my bookmarks from my desktop and then import them into Firefox on my laptop. The Help file tells me to open "Organize Bookmarks" 'but I can't find it! Help!

    Sorry, that menu item was renamed. You want "Show All Bookmarks" now.

  • HT1178 I have BT Infinity at home with the BT modem connected to the phone line and then to a BThub which delivers the wif signal. I have purchased an airport extreme to improve wi fi strength if how do I connect up to hub it states connect modem to WAN o

    I have BT Infinity at home with the BT modem connected to the phone line and then to a BThub which delivers the wif signal. I have purchased an airport extreme to improve wi fi strength if how do I connect up to hub it states connect modem to WAN on back of Airport Extreme.
    Instructions do not mention connection to BT Hub and the BT modem has only one output which you dicsonnect from Hub and connect to airport extreme leaving. Once you do this Hub has no signal.
    How do I rectify
    Paul

    you can also set up the Airport extreme to extend the wireless by hitting the wireless tab in the airport menu then click the drop down menu to select extend
    Apple's "extend" function is a proprietary setting that was designed to only work with other Apple routers.
    It would be extremely unlikely that this setting would work with a BT product, or any other manufacturer's product for that matter.
    But, I haven't tested this with a BT product...and I suppose anything is possible.
    Still, I would be extremely surprised if this worked.
    The AirPort Extreme might "join" the BT network if you try this......but the AirPort does not provide any additional wireless signal coverage when it "joins" a wireless network. In fact, it really does nothing when it "joins" a network except enable the USB port.

  • In My iphone 5s,i have disabled automatic download from whatsapp app.So whichever images,video i feel is good i download them and then save them to my camera roll section.So i want to know how can i remove the images from cache of my phone.

    In My iphone 5s,i have disabled automatic download from whatsapp app.So whichever images,video i feel is good i download them and then save them to my camera roll section.So i want to know how can i remove the images from cache of my phone which are downloaded and not saved,but they remain in cache.
    Even in some apps i have data which i want to remove,but cant find a way to remove them and they are in my cache eating up my memory.

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • Is there a way to select all emails at once on the iPad and then delete them at one time?

    Is there a way to select all emails at once on the iPad and then delete them at one time?

    Tap on the edit button at  the top right of the email list. This will let you select the emails to delete, once all are selected, tap on the bottom right button that says delete to delete them all at once.

  • Since I have the newest version of itunes, I can't back up like normally. The only way is to considilate files and then put them on an external drive which I don't have. Are there any other options? If I can't back up to a disc like I used to, can I inste

    Since I have the newest version of itunes, I can't back up like normally. The only way is to considilate files and then put them on an external drive which I don't have. Are there any other options? If I can't back up to a disc like I used to, can I instead just keep everything on my ipod and then if I have to get a new computer or something just download all my songs from the ipod to my new computer's itunes? Will that work? Will I still be able to keep all my songs that way?

    I'm going to assume the consolidating files does not work due to hard drive space limitations.
    Since you're moving to Windows 7, have you tried using the Windows files and settings transfer utility?  That will move everything for you to the same location on the new computer, it also allows some control over what actually gets moved.
    Alternatively, if you know the location of all of the media, it can be manually moved by copying it from the old computer to the new computer in the same location.
    Also, using the Apple article on moving the library, take a slight twist on what it says.  Move the iTunes library to the external drive, update the settings in iTunes to reflect the library being on the external drive, then consolodate it.
    The options are endless for moving the library... it simply takes a little effort to make it happen and possibly a twist on existing "standard" methods depending on your unique situation.

  • Can you edit AVCHD movies and then export them as AVCHD losslessly?

    As the title suggests, is it possible to create an AVCHD project in iMovie with AVCHD files (1920x1080 60p) edit them and then export them losslessly with a new Imac? I know of only one program that can do that and that one doesn't allow anything other than simple cuts & trims. You can't add music or any sophisticated editing.

    No.

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • I previoulsy have adding many CD to my iTunes music library and then synched them with my iPhone so that I have all music in both places. And I could the CDs in iTunes or iPhone with no problems. Recently, my iTunes "sees" the music but won't play it. Why

    I have added many CD to my iTunes music library and then synched them with my iPhone so that I have all music in both places. Then I could the play them in iTunes or iPhone with no problems. Recently, my iTunes "sees" the music library but won't play any of it becuase "the original could not be found". If I attach my iPhone, then it pays them through the iPhone, but still not through the library in iTunes. How can I get the music library on my iPhone to transfer (i.e. restore it) to iTunes? I have iPhone 4S but have not upgraded to the iOS 6, and have not had any problems until last week.  Help!  Thanks.

    Check the manual for whatever backup program you used, or, if you just copied the files over, copy them that.
    How to restore data to your PC is outside the scope of these forums.

  • Can I export my itunes movies onto an external hard-drive and then remove them from my computer, but still watch them when I plug in my external hard-drive?

    I am running out of space on my macbook. What is taking up the most room is my movies. Can I put them on an external hard-drive and then watch them later after I remove them from my library?

    tothatc wrote:
    Hello,
    I recently purchased a new laptop because my old computer wwent on the fritz.  Luckily I backed up my library on my external hard drive. My question is can a) connect my itouch and ihone to my nex computer and b) run my library strictly from my hard drive and not import everything to my new computer?
    thanks for the hep!!
    On Windows, hold Shift (not alt), launch iTunes and select Choose library... and select the iTunes folder you copied to the external drive.

  • Is it possible to save an iPhone back up and access the files later if needed?  I have a string of text sms and iMessages that I would like to save and then delete them from my phone.  Is this possible?

    I have a string of text sms and iMessages that I would like to save and then delete them from my phone, but gain access to them later if I need them.  I prefer to have the string with the date/time stamp vs copying and pasting into a doc or text file.  Is this possible?

    Not unless you buy an app that accesses data from an iTunes backup.  Check in the app store.

Maybe you are looking for