Java web crawler

Crawler Introduction

In this tutorial, you will learn how to crawl a website using java. Before we start to write java web crawler we will see how a simple web crawler is designed. What is a crawler? A web crawler is a program that browses the World Wide Web. Web crawlers are also known as spiders, bots and  automatic … Read more

extundelete, Recover deleted files in Ubuntu

Download and make extundelete Run this script to download and compile extundelete from source Recover Files Get drive name Now that the extundelete is compiled, you would need to check the name of the drive to recover. And that can done by: Restore Restore all Restore a directory Restore a directory after a date/time In … Read more

How to refactor enum to class

In this tutorial we will see how to refactor an enum.  I was recently working on a small project that was using an enum to manage some constants. But we had to change this enum to a class due to change of requirements. Overview Let’s say that a project was allowing users to choose from … Read more

How to get the intersection of two collections in java

With collections it is very easy to get the intersection of two collections. Here is a simple example which creates two lists and then gets the intersection of two lists. We would be using retainAll(Collection<?> c).  One thing that you should be aware of is that the list on which retainAll method is invoked will contain … Read more

Compress and decompress byte[] in java

Here is a simple utility that compresses and decompresses a byte[] array. I have been using this utility to compress serialized objects before storing to and after retrieving them from the database. I have found it very useful. I have added a main method to just show that how the compression works. output: For more … Read more

Convert int[] to Integer[] and vice versa in java

Here is a simple example to convert primitive int array to Integer array and vice versa Using regular for-loop And the output is : Java 8 Using Stream APIs of Java 8. Commons Arrayutils If you are not using java 8 and still want to have a oneliner. Use ArrayUtils from commons-lang3. References … Read more

JavaFx Helloworld

In this example we will create a simple Helloworld application for JavaFx. I have added inline comments to the code. And here is the output   Notes In case you are using this HelloWorld in eclipse and you get the below warning. Access restriction: The type Pane is not accessible due to restriction on required … Read more

Distribute your code in a unique style

So let’s have a look at a very interesting way of loading a class. We have a very simple class. There is nothing special about it. It just prints text in constructor. This class prints the bytecode of the UnIntrestingClass. This class just shows how to print the bytecode. It prints Let … Read more

Convert byte[] array to String in Java

In this tutorial we will see how to convert a byte[] to String. It can be useful in cases where a String is stored as a byte[] array and needs to be converted to String. Java API Used This can be easily achieved by using the constructor provided by String class that accepts the byte[] … Read more