Categories
Article

Visual Studio Code Cloning a GIT Repository

Visual Studio Code is an open-source and free IDE for programmers. It has community-based plug-ins for different works. Nowadays it is one of the most widely used IDE for many development languages and platforms. The most important thing is that it runs on many platforms like Windows, Mac, Linux. It can be downloaded from it […]

Categories
Article

GIT Uses in Eclipse Guide

Eclipse IDE is the most widely free open source editor mostly used by Java developers. It comes in many trims packages like Eclipse  Java, J2ee, Php, C/C++. It has an array of Plug-ins support by community and commercials licenses. Now most of the Eclipse IDE has a preconfigured GIT repository integration tool, if your installation […]

Categories
Java

Rest Client For Java using HttpClient and Jakson

There are many HttpClient and Rest Clients lib is available for Java developers. The most common is Spring Rest Template for REST client and Apache HttpClient a generic HTTP client. I personally like the Apache HttpClient library for making REST calls and Http Calls. I found one generic kind of REST client using Apache HttpClient […]

Categories
Java

Java HttpClient POST, PUT and Patch Example with Body

Java HttpClient library from Apache is very good, it provides many interfaces to perform different operations like  POST, PUT, and PATCH. One can also send String or URI encoded form and another payload very easily using the HttpEntity interface. You can easily add query strings and custom headers. To post JSON string, XML, or simple […]

Categories
Java

HttpClient Java Get Example with Query String and Custom Headers

Apache HttpClient java library is my most preferred HttpClient library for making HTTP requests. One can easily add parameters, body, and custom headers with clean interfaces. Since version 4.0 it also provides EntityUtils to read the response from HttpResponse into string and byte arrays. Here is a complete example to make get requests with parameres […]

Categories
Java

Quickest way to append text to a file in Java

In Java, there are several different ways to append text in a file. For file operations, Java provides several classes. To appending text quickly you can use Files class. Append text to file example: try { Files.write(Paths.get(“file1.txt”), “text to append”.getBytes(), StandardOpenOption.APPEND); } catch (IOException e) { // To exception handling here } But above method […]

Categories
Java

How does Java for-each loop works?

Loops in programming languages used to iterate over collections like for loop, while .. do etc. In Java iterating over collections looks very ugly. Consider method in the following example which uses for loop to iterate over a collection. public static void main(String[] args) { List fruitList = new ArrayList(); fruitList.add(“mango”); fruitList.add(“banana”); fruitList.add(“apple”); printFruits(fruitList); } […]

Categories
Java

Apache HttpClient with CookieStore (cookie support) in Java

In java many time we need to make a request with cookies support. For example, if a REST service is configured to manage session using cookie session or cookie-based session key then we need to use HTTP client with cookie support. For this Apache HttpClient client provides HttpClientBuilder Class, CookieStore interface and BasicCookieStore. Using these […]

Categories
Java

Manually Closing connection of Apache HttpClient in Java

While Using Apache HttpClient library to make Http requests, we should always release connection immediately after completion of the operation. For making HttpRequest Apache HttpClient library provides CloseableHttpClient and CloseableHttpResponse classes which implements java closable interface. By calling the close method of a closeable object in finally block we can close or dispose of connection […]

Categories
Java

Apache HttpClient Response Hadling in Java

Apache HttpClient library provides the ResponseHandler interface. By implementing ResponseHandler you can handle HTTP responses in a clean way. Using the response handler is the recommended way of executing HTTP requests and processing HTTP responses. This approach of handling response enables the caller to concentrate on the process of digesting HTTP responses and to delegate […]