Ooh … Begitu! I see, I see …

Icon

Setelah kelayapan di internet, cari-cari info dari sana-sini dan bongkar pasang tips (terutama programming), akhirnya baru sadar … ternyata begitu caranya … [all about tricks and tips I have found during my work as programmer.]

how to check if two filename paths refer to the same file?

I just found out the information that a filename path may include redundant names such as ‘.’ or ‘..’ or symbolic links (on UNIX platforms).
so how to know exactly if two filename paths are referring to the same file?

use File.getCanonicalFile() to convert a filename path to a unique canonical form suitable for comparisons. and then, compare the results of both getCanonicalFile() with equals(…)

just take a look at this example below to get some idea.

    public boolean isSameFile() {
        File file1 = new File("./filename");
        File file2 = new File("filename");
        
        // Filename paths are not equal
        // false, don't use this way to compare.
        boolean b = file1.equals(file2);                
        
        // Normalize the paths first.
        try {
            // D:\\sth\\filename
            file1 = file1.getCanonicalFile(); 

            // also D:\\sth\\filename
            file2 = file2.getCanonicalFile(); 
        } catch (IOException e) {
            // your exception lines...
        }
        
        // Filename paths are now equal.
        return file1.equals(file2);              // true
    }

I got this information from www.exampledepot.com there are more interesting tips about file handling in Java programming. just make sure you won’t miss those tips too. 🙂

have a nice day of coding.

Advertisements

Filed under: Java programming, , ,

maximize a JFrame??

hi, there.
is there any way to maximize a JFrame??

thanks for your responding.

sure. add this line:

this.setExtendedState(this.getExtendedState() | 
                            this.MAXIMIZED_BOTH);

hope this helps. 🙂

Filed under: Java programming, , ,

to close singleton JInternalFrame the default way, but not using dispose()???

hi, I read your close a singleton JInternalFrame from an outsider customized JPanel tips and I had a problem with that.

remember your line about to close the singleton JInternalFrame from its separated customizeable JPanel coding?
getRootPane().getParent().setVisible(false);

this was only to setVisible to false. now if I want to close it (but still, do it according to my setDefaultCloseOperation(HIDE_ON_CLOSE); method). how to do that?

to call dispose(); won’t solve the problem. this would really call the dispose as its close operation. I just wanna make sure my singleton JInternalFrame would do the default close operation whatever I would set onto the setDefaultCloseOperation(…); thingy. do you know how to do it?

thanks for your help.

thanks for reminding me. I just found it too …

((JInternalFrame) getRootPane().
        getParent()).doDefaultCloseAction();

doDefaultCloseAction(); will serve it well.
thanks for dropping by and asking. have a nice day of coding … 🙂

Filed under: Java programming, ,

rojak language, manglish and singlish

alamak! another variety of language and English? really meh?
hmm … I checked it liao … after ting ting and read read for a while, I ting dis is so creative combination hoo? why not? 😉

why beh say do it ah (why mustn’t do it)? it’s so cool lor … 😀

wan example from http://ahpek.com/index.php/using-good-manglish/, you see this true English version hoo

Yesterday, my girlfriend and I went to the movies. We met up the the KFC outlet where she got some fries. After the movie, we went back to my house and since my mother was not around, we decided to go to my room.

n dis is d Manglish one …

Barger, yesterday when me and my girlfriend want to go and see picture that time, she said she wanted to eat French fries so I asked her to wait at Kentucky lah. Mana tau, reach there that time, saw so many people lining up sampai want to wait also cannot already because the picture starting at 9. After the picture finished, I ask my girlfriend to come to my house so that we can screw screw a bit lah. My mother not in mah.

see? very creative way of English sentence building mah?

just kan kan it out lah:mrgreen:
http://en.wikipedia.org/wiki/Manglish
http://en.wikipedia.org/wiki/Singaporean_English
http://en.wikipedia.org/wiki/Rojak_Language

Filed under: english, hilarious