HTML

5 Best Gifts for Programmers,Software Developers and Tech Geeks 2017 - 2018

So, its that time of the year again when you start thinking about gifts for your programmer boyfriend, husband, colleagues or your near dear ones. Even if selecting gifts were not tough, if your friend happened to be a programmer, it becomes slightly tougher. You might have heard that Programmers are aloof, nerd and tech freaks, well, you heard it right. Programmers  prefers to be alone in their own world but they also like gifts and you got it right, they are a nerd so they like books, gadgets, music and something which help them to learn something e.g. a PluralSight membership.

In 2017, gadgets like Apple Watch and Samsung Gear is rocking but that's what everyone is buying so if you want to be a little bit different, chose the one from this list.

How to test RESTful Web Services using curl command in Linux

The curl command of Linux is very powerful and versatile command which allows you to send sophisticated HTTP request right from Linux command line. You can use curl to test your RESTful Web Services by sending GET and POST request, doing authentication, saving a cookie in the file etc. The curl command is the go-to tool for many Java and Spring developers for consuming the secured RESTful Web Services, but you can also use it test your simple REST Web APIs without security.

3 ways to convert String to byte array in Java - Example Tutorial

Today, I am going to discuss one of the common tasks for programmers, converting a String to a byte array. You need to do that for multiple reasons e.g. for saving content to a file, sending over a network or maybe some other reason. Suppose you have a String "abcd" and you want to convert it into a byte array, how will you do that in a Java program? Remember, String is made of the char array, so it involves character to byte conversion, which is subject to character encoding intricacies. Thankfully, Java provides a convenient getBytes() method to convert String to byte array in Java, but unfortunately, many developers don't use it correctly. Almost 70% of the code I have reviewed uses getBytes() without character encoding, leaving it on the chance that platform's default character encoding will be same as of the source String.

How to convert primitive int value to a Long object in Java?

Suppose you have an int variable but the part of the application is expecting a Long object, how do you convert a primitive int to a Long object in Java? It shouldn't be a problem, right? after all long is a bigger data type than int, so all int values are acceptable as long, but we also need a Long object, not just the long primitive value. Now, the problem is reduced to converting a long primitive to Long object, which is not really a problem if you are running on JRE version higher than Java 5. But, sometimes autoboxing is not efficient e.g. when you have to convert multiple long values into the Long object in a loop. A better way to convert your long primitive to the Long object is by using static factory methods like Long.valueOf(long l), which was originally meant to convert long primitive values to a Long object, prior to Java 5, but, also works fine with int primitive.

How to convert comma separated String to ArrayList in Java - Example Tutorial

Suppose you have a comma separated list of String e.g. "Samsung, Apple, Sony, Google, Microsoft, Amazon" and you want to convert it into an ArrayList containing all String elements e.g. Samsung, Apple, Google etc. How do you do that? Well, Java doesn't provide any such constructor or factory method to create ArrayList from delimited String, but you can use String.split() method and Arrays.asList() method together to create an ArrayList from any delimited String, not just comma separated one. All you need to do is first split the given String on delimiter e.g. comma using the split() method, this will give you an array of String. Now, you can pass that array to Arrays.asList() method to create a List, but remember this would be fixed length list and not truly an ArrayList.