How-to articles, tricks, and solutions about JAVA
To call a SOAP web service on Android, you can use the HttpURLConnection class to send an HTTP request to the web service and receive the response.
In Spring MVC, the @ModelAttribute annotation is used to bind request parameters to method arguments in controller methods.
To pass a parameter to a Java thread, you can use a Runnable object and pass the parameter to its constructor.
To use a Java 8 lambda to sort a stream in reverse order, you can use the sorted() method of the Stream interface and pass a lambda function that compares the elements in reverse order.
To tell if a character is a letter or number in Java without using regexes, you can use the Character class and its isLetter() and isDigit() methods.
To break or return from a Java 8 Stream.forEach() operation, you can use the break or return statements as you would normally do in a loop.
To find the difference between two LocalDateTime objects in multiple units, you can use the Duration class.
To install JDK 11 under Ubuntu, follow these steps:
A .jar file is a Java Archive file that contains compiled Java code and resources (such as images, sounds, etc.) that can be used by Java applications.
RecyclerView does not have an onItemClickListener() method because it is not directly responsible for displaying a list of items.
To connect to a SQL Server database using JDBC, you will need to use the JDBC driver for SQL Server.
To run a single test method with Maven, you can use the surefire:test goal and specify the fully-qualified name of the test class and the method name using the test and method properties, respectively.
To get the POST request body from an HttpServletRequest object in Java, you can use the getReader method of the ServletRequest interface to read the request body as a BufferedReader and then use the readLine method to read the data as a string.
To get JSON POST data from an HttpServletRequest object in Java, you can use the getReader method of the ServletRequest interface to read the request body as a BufferedReader and then use the readLine method to read the data as a string.
To check if a string contains a number and extract the number from the string in Java, you can use a combination of the matches method of the String class and the find method of the Matcher class.
To remove the last character of a StringBuilder in Java, you can use the deleteCharAt method and pass in the index of the character you want to delete.
The default maximum heap size for the Java heap is determined by the amount of physical memory available on the system.
If you want to use the @JsonIgnore annotation to ignore a field during serialization but not during deserialization, you can use the @JsonIgnoreProperties annotation and set its writeOnly property to true.
To check if a folder exists in Java, you can use the java.nio.file.Files class and its exists method.
To remove leading and trailing whitespace from a string in Java, you can use the trim method of the String class.
To create a directory in Java if it does not exist, you can use the java.nio.file.Files class and its createDirectory method.
To send an HTTP GET request in Java, you can use the java.net.URL and java.net.HttpURLConnection classes.
To get a substring from a string in Java up until a certain character, you can use the indexOf method to find the index of the character and then use the substring method to extract the substring.
C++ is generally considered to be a faster and more performant language than Java or C#.
The java.net.SocketTimeoutException: Connection timed out error usually occurs when a client is trying to connect to a server, but the connection request is taking too long to complete.