Posts

Showing posts from June 29, 2010

How to calculate number of files in a directory in java code examples

 private static int calNoOfFiles(String directoryPath)     {         String fileDelimiter= File.separator;         File fd = new File(directoryPath);         if(!fd.isFile())         {             String list[] = fd.list();             for(int i = 0; i < list.length; i++)             {                 String tempDirPath = directoryPath + fileDelimiter + list[i];                 debug(tempDirPath);                 File ftd = new File(...

How to get file extension in java code example

Get file extension in java code example public static String getFileExtension(String filePath)     {         File f = new File(filePath);         String name = f.getName();         int k = name.lastIndexOf(".");         String ext = null;         if(k != -1)             ext = name.substring(k + 1, name.length());         return ext;     }

What is inner class in java code example

public class Test {             public void MethodOne() {                 System.out.println("Inside Test class");         }                 public class InnerC {             public void MethodOne() {                 System.out.println("Inside InnerC class");             }                     public void test() {                 this.MethodOne();                 Test.this.MethodOne();         ...

What are Boxing, Autoboxing and Auto-Unboxing in java example

Boxing :- Convert primitive data to its wrapper class object.    Example :- char to Charactor               int to Integer               boolean to Boolean               float to Float           double to Double; Unboxing :- Java primitive type  to its wrappers class:    Example :-     Boolean to boolean          Byte to byte,         Character to char,                 Double to double,                 Float to float,         Long to long,    ...

What is the use of startsWith and endsWith method in String java example

// What is the use of startsWith and endsWith method in String java example public class Test {         public static void main(String[] args) {                    String st = new String("test string test here");                         System.out.println(st.startsWith("test"));             System.out.println(st.startsWith("test", 12));                         System.out.println(st.endsWith("here"));                     } }

Recent Post

Recent Posts Widget