Posts

Interceptor in struts2 java

Interceptor Definition:-                      In struts2, An Interceptor is an interface under the com.opensymphony.xwork2.interceptor package. An Interceptor extends the Serializable Interface. An interceptor is a stateless class that follows the interceptor pattern.     Interceptor give the choice to write code that can be invoke before and after the execution of an action. Interceptor also have the facility to stop an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions.

Directory Size in java code example

How to get Directory Size in java code example? public static long getDirectorySize(String directoryPath)     {         dirSize = 0L;         dirSize = calDirectorySize(directoryPath);         return dirSize;     }  private static long calDirectorySize(String directoryPath)     {         File fd = new File(directoryPath);         if(!fd.isFile())         {             String list[] = fd.list();             for(int i = 0; i < list.length; i++)             {                 Stri...

String Array to String separator java

How to convert String Array to String with separator java code, Examples public static String arrayToString(String[] a, String separator) {     String result = "";     if (a.length > 0) {         result = a[0];    // start with the first element         for (int i=1; i             result = result + separator + a[i];         }     }     return result; }

replaceall in javascript example

ReplaceAll method in java script. function ReplaceAll(content,findWith,replaceWith){   var str = content;     var index = str.indexOf(findWith);         while(index != -1){             str = str.replace(findWith,replaceWith);             index = str.indexOf(findWith);         }         return str; }

get System Time in java code Example

How to get System Time in java code Example. public static String getSystemTime()     {         DateFormat df = DateFormat.getTimeInstance(3);         df.setTimeZone(TimeZone.getDefault());         String sec = new String("" + df.getCalendar().get(13));         String min = new String("" + df.getCalendar().get(12));         String hr = new String("" + df.getCalendar().get(11));         if(sec.length() < 2)             sec = "0" + sec;         if(min.length() < 2)             min = "0" + min;         if(hr.length() < 2)         ...

Open color dialog box in applet java code

How to open color dialog box in applet java code. public class ColorDialog extends Dialog {     public ColorDialog(Frame p)     {         super(p, "Color Dialog", true);         OK_button = new Button("OK");         Cancel_button = new Button("Cancel");         OK_Cancel = new Panel();         init();         show();     }     public ColorDialog(Frame p, Color c)     {         super(p, "Color Dialog", true);         OK_button = new Button("OK");         Cancel_button = new Button("Cancel");         OK_Cancel = new Panel();         init();         color_panel.setCurColor(c);      ...

check string is number or not in java code example

  check string is number or not in java code example public boolean isStrNumber(String str){           try{               Integer.parseInt(str);           } catch(NumberFormatException nfe) {           return false;           }           return true;           }

Recent Post

Recent Posts Widget