Posts

convert Object Array to String in java examples

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

write pdf file using java with itext

Make a pdf file through itext jar in java write pdf file using java with itext import com.itextpdf.text.Document; import com.itextpdf.text.PageSize; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; import java.io.FileOutputStream; /**   * @Manoj Shakya  */ public class Test {     public static void main(String [] aa){         try{         Document document = new Document(PageSize.A4, 10, 10, 10, 10);         PdfWriter.getInstance(document, new FileOutputStream("C:\\test.pdf"));         document.open();         PdfPTable bodytable = new PdfPTable(6);                 for(int i=0; i<5; i++){             bodytable...

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)         ...

Recent Post

Recent Posts Widget