• 30 January

    How to get all files with certain extension in a folder in java

    In this post, we will see how to list all files with certain extension in a folder. For example, you want to list all .jpg or .zip files in a folder. We will  use FilenameFilter interface to list the files in a folder, so we will create a inner class which will implement FilenameFilter interface and implement […]

  • 30 January

    How to delete non empty directory in java

    In this post, we will see how to delete Directory/Folder which is non empty. You can use java.io.File ‘s delete empy folder but you can not delete it if it is non empty. There are multiple ways to do it. Using java recursion Using Apache common IO Using java recursion: It is very straight forward to […]

  • 30 January

    How to download file from URL in java

    In this post, we will see how to download file from URL in java. It can be used when you want to automatically download any file from URL using java. There are many ways to do it and some of them are : Using Java input output stream Using apache common IO Using NIO Java […]

  • 30 January

    How to check if a file exists in Java

    It is very easy to check if file exists or not in your file system. You can use java.io.File’s exists() method to check if file exists or not. Java program : [crayon-65f95f1cb2be5038576823/] When you run above program, you will get following output: [crayon-65f95f1cb2bea051071441/]

  • 29 January

    Java get file extension

    In this post, we will see how to get extension of file in java. As java.io.File does not provide any direct method for getting extension of file. This is used when you want to process file differently on the basis of its extension. I have worked on a project where I required this utility method. […]

  • 29 January

    How to get size of file in java

    In this post, we will see how to get size of file in java. We can directly use java.io.File ‘s length method to get its size in bytes. We can convert it to KB and MB accordingly. [crayon-65f95f1cb2e26343180334/] When you run above program, you will get following output: [crayon-65f95f1cb2e2a524751060/]

  • 25 January

    How to Convert Date to String in Java

    In this post, we will see how to convert date to string in java. It is more of utility which is mostly used while displaying dates in different string formats while generating any pdf or excel reports.You may also check how to convert string to date Java program: [crayon-65f95f1cb2f05931478181/] When you run above program, you […]

  • 25 January

    How to convert String to Date in java

    In this post, we will see how to convert String to Date object in java. It is used when we have formatted String and need to convert it to Date object.You may also check how to convert Date to String Java program: [crayon-65f95f1cb2ff0446185466/] When you run above program, you will get following output: [crayon-65f95f1cb2ff4451554352/]

  • 23 January

    Spring Quartz Scheduler Example

    In this post, we will see how to schedule jobs using Spring Quartz scheduler or how to integrate spring with Quartz. We have already seen how to schedule jobs using Timer and TimerTask . There are two ways by which you can specify quartz jobs. MethodInvokingJobDetailFactoryBeanJobDetailFactoryBean JobDetailFactoryBean is used for complex task. You need to create job […]