Wednesday, July 28, 2010

Replace String pattern in "Vi"

1) Open the TEXT file using "vi" editor in linux.
2) Press ESC
3) Following command will replace "tab" character by "|".

    :%s/    /|/g

4) Save & quit file using following command.

    :wq!

Monday, July 19, 2010

Java property file usage

Use the below code to read the java property file and retrieve the property value.
 
      Properties properties = new Properties();
        FileInputStream in;
        try {
            in = new FileInputStream("app.properties");
            properties.load(in);
            in.close();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return properties.getProperty("appcode");

Sample "app.properties" file is shown below.

appcode=50
email=admin@yahoo.com

Tuesday, July 6, 2010

From date < To date validate using js

Use the below js code to validate date "From date < To date"

         var frmDate = document.getElementById("frmDate").value;
         var toDate = document.getElementById("toDate").value;

         if (frmDate < toDate) {
               alert("Invalid Date Range!\nStart Date cannot be after End Date!")
               return false;
           }