HowToDoInJava https://howtodoinjava.com Sun, 17 Jun 2018 16:24:58 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.6 https://howtodoinjava.com/wp-content/uploads/2015/05/howtodoinjava_logo-55696c1cv1_site_icon-32x32.png HowToDoInJava https://howtodoinjava.com 32 32 Create List with Single Element https://howtodoinjava.com/core-java/collections/create-list-with-single-element/ https://howtodoinjava.com/core-java/collections/create-list-with-single-element/#respond Wed, 06 Jun 2018 14:10:48 +0000 https://howtodoinjava.com/?p=10510 Learn to create List instances with only one element in it using Arrays.asList() and Collections.singletonList() methods. Using Collections.singletonList() Method [ Immutable List ] This is simplest and recommended method to create immutable List with single element inside it. The list created with this method is immutable as well, so you are sure that there will […]

The post Create List with Single Element appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/collections/create-list-with-single-element/feed/ 0
Log4j2 LevelRangeFilter Example https://howtodoinjava.com/log4j2/levelrangefilter-example/ https://howtodoinjava.com/log4j2/levelrangefilter-example/#respond Sat, 02 Jun 2018 19:15:08 +0000 https://howtodoinjava.com/?p=10480 Learn to use log4j LevelRangeFilter filter which returns the onMatch result if the level in the LogEvent is in the range of the configured min and max levels, otherwise it returns onMismatch value. LevelRangeFilter example In given log4j2.xml file, we have used to LevelRangeFilter to filter log levels in such a way that : All […]

The post Log4j2 LevelRangeFilter Example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/log4j2/levelrangefilter-example/feed/ 0
Log4j2 Multiple appenders example https://howtodoinjava.com/log4j2/multiple-appenders/ https://howtodoinjava.com/log4j2/multiple-appenders/#respond Sat, 02 Jun 2018 19:02:14 +0000 https://howtodoinjava.com/?p=10443 Given log4j2.xml is reference to configure multiple appenders such as console appender and file appenders. This also configure the dynamic log root path. Log4j multiple appenders configuration Sample log4j configuration is given blow. It does following things: Uses dynamic log root path where log files will be created. Pass environment variable as -DAPP_LOG_ROOT=c:/temp to configure […]

The post Log4j2 Multiple appenders example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/log4j2/multiple-appenders/feed/ 0
Spring @Async and @EnableAsync example https://howtodoinjava.com/spring/spring-boot2/enableasync-async-controller/ https://howtodoinjava.com/spring/spring-boot2/enableasync-async-controller/#respond Sat, 02 Jun 2018 18:13:55 +0000 https://howtodoinjava.com/?p=10406 Learn to create asynchronous methods in Spring framework with the help of @Async and @EnableAsync annotations, async thread pool on top of Java ExecutorService framework. Spring @Async configuration Spring comes with @EnableAsync annotation and can be applied on application classes for asynchronous behavior. This annotation will look for methods marked with @Async annotation and run […]

The post Spring @Async and @EnableAsync example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/enableasync-async-controller/feed/ 0
Spring Boot Log4j2 Example https://howtodoinjava.com/spring/spring-boot2/spring-boot-log4j2-config/ https://howtodoinjava.com/spring/spring-boot2/spring-boot-log4j2-config/#respond Fri, 01 Jun 2018 09:28:27 +0000 https://howtodoinjava.com/?p=10462 Spring boot’s default logging uses Logback which is included as transitive dependency. Spring Boot supports Log4j 2 for logging configuration if it is on the classpath.

The post Spring Boot Log4j2 Example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/spring-boot-log4j2-config/feed/ 0
Java – Append to File https://howtodoinjava.com/core-java/io/java-append-to-file/ https://howtodoinjava.com/core-java/io/java-append-to-file/#respond Wed, 30 May 2018 03:48:48 +0000 https://howtodoinjava.com/?p=10432 Learn to append content to file in java using BufferedWritter, PrintWriter, FileOutputStream and Files class. In all the examples, while opening the file to write, you have pass a second argument as true which denotes that file is opened in append mode. Table of Contents Append to File using BufferedWritter Append to File using PrintWriter […]

The post Java – Append to File appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/io/java-append-to-file/feed/ 0
Java – Write to File https://howtodoinjava.com/core-java/io/java-write-to-file/ https://howtodoinjava.com/core-java/io/java-write-to-file/#respond Tue, 29 May 2018 18:29:25 +0000 https://howtodoinjava.com/?p=10430 When working on enterprise application, sometimes it is needed to write files in java e.g. writing reports in filesystem.. Though, there are multiple ways to do so, let's quickly go through few of them for quick reference when it is needed.

The post Java – Write to File appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/io/java-write-to-file/feed/ 0
Java 10 Features and Enhancements https://howtodoinjava.com/java10/java10-features/ https://howtodoinjava.com/java10/java10-features/#respond Mon, 28 May 2018 18:19:32 +0000 https://howtodoinjava.com/?p=10421 After Java 9 release, Java 10 came very quickly. Unlike it’s previous release, Java 10 does not have that many exciting features, still it has few important updates which will change the way you code, and other future Java versions.

The post Java 10 Features and Enhancements appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/java10/java10-features/feed/ 0
Java Version – Time-Based Release Versioning https://howtodoinjava.com/java10/java-version/ https://howtodoinjava.com/java10/java-version/#respond Mon, 28 May 2018 04:26:02 +0000 https://howtodoinjava.com/?p=10412 Starting from Java 10, Oracle has adapted time based version-string scheme [JEP 322]. The new time-based model has replaced the feature-based, multi-year release model of the past. Unlike the old releases, the new time-based releases will not be delayed and features will be released every six months, with no constraints on what features can go […]

The post Java Version – Time-Based Release Versioning appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/java10/java-version/feed/ 0
Java var – Local-Variable Type Inference https://howtodoinjava.com/java10/var-local-variable-type-inference/ https://howtodoinjava.com/java10/var-local-variable-type-inference/#respond Sun, 27 May 2018 17:44:15 +0000 https://howtodoinjava.com/?p=10409 Java has been progressively working on reducing the verbosity from syntax. First it was Diamond operator, and now it is var (local variable type – JEP 286) to declare variables in java. When you are using var to declare the variable, basically, instead of declaring a variable type, it assumes its type from what it […]

The post Java var – Local-Variable Type Inference appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/java10/var-local-variable-type-inference/feed/ 0
Java Comments https://howtodoinjava.com/core-java/basics/java-comments/ https://howtodoinjava.com/core-java/basics/java-comments/#respond Fri, 18 May 2018 12:33:59 +0000 https://howtodoinjava.com/?p=10373 Java comments, as name suggests, are notes you write between the programs for various reasons. For example, you may write comments to – write information or explanation about the variable, method, class or any statement. write text to be available in Java docs. hide program code for specific time, etc. Types of Java Comments There […]

The post Java Comments appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/basics/java-comments/feed/ 0
Java Variables https://howtodoinjava.com/core-java/basics/java-variables/ https://howtodoinjava.com/core-java/basics/java-variables/#respond Thu, 17 May 2018 11:44:29 +0000 https://howtodoinjava.com/?p=10369 As term suggest, a variable is whose value can vary during the runtime. In Java, a variable is a named reference to a memory area where value of the variable is stored. A variable declaration has following syntax: [data_type] [variable_name] = [variable_value]; data_type – refer to type of information stored in memory area. variable_name – […]

The post Java Variables appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/basics/java-variables/feed/ 0
Differences between JDK, JRE and JVM https://howtodoinjava.com/core-java/basics/jdk-jre-jvm/ https://howtodoinjava.com/core-java/basics/jdk-jre-jvm/#respond Thu, 17 May 2018 09:42:17 +0000 https://howtodoinjava.com/?p=10367 JDK, JRE and JVM is very common words when developers talk about java applications and their development environments. Let's find out the differeneces between these words.

The post Differences between JDK, JRE and JVM appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/basics/jdk-jre-jvm/feed/ 0
Python – endswith examples https://howtodoinjava.com/python/endswith-examples/ https://howtodoinjava.com/python/endswith-examples/#respond Mon, 14 May 2018 10:53:56 +0000 https://howtodoinjava.com/?p=10346 Python examples to to check the end of a string for specific text patterns e.g. domain name extenstions and so on. Use endswith() with strings A simple way to check the end a string is to use the String.endswith(). Use endswith() with tuples If you need to check against multiple choices, simply provide a tuple […]

The post Python – endswith examples appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/endswith-examples/feed/ 0
Python – startswith examples https://howtodoinjava.com/python/python-startswith/ https://howtodoinjava.com/python/python-startswith/#respond Mon, 14 May 2018 10:48:05 +0000 https://howtodoinjava.com/?p=10345 Python examples to to check the start of a string for specific text patterns e.g. URL schemes and so on. Use startswith() with strings A simple way to check the beginning a string is to use the String.startswith(). Use startswith() with tuples If you need to check against multiple choices, simply provide a tuple of […]

The post Python – startswith examples appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/python-startswith/feed/ 0
Python – Split String example https://howtodoinjava.com/python/split-string/ https://howtodoinjava.com/python/split-string/#respond Mon, 14 May 2018 10:21:51 +0000 https://howtodoinjava.com/?p=10341 Python example to split string into fields using the delimiters in the string. Split string using split() method Easiest way to split a string using a delimiter is using string.split( delimiter ) function. Split string with multiple delimiters The split() method of string objects is really meant for very simple cases, and does not allow […]

The post Python – Split String example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/split-string/feed/ 0
Python – Find common data or dictionary intersection https://howtodoinjava.com/python/common-data-intersection/ https://howtodoinjava.com/python/common-data-intersection/#respond Sat, 12 May 2018 11:30:44 +0000 https://howtodoinjava.com/?p=10340 Python example to find common items between 2 or more dictionaries i.e. dictionary intersection items. Find common items using ‘&’ operator Simplest method is to use & operator between dictionaries. Use set.intersection() method Happy Learning !!

The post Python – Find common data or dictionary intersection appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/common-data-intersection/feed/ 0
Python – OrderedDict ( Ordered Dictionary ) https://howtodoinjava.com/python/ordereddict-ordered-dictionary/ https://howtodoinjava.com/python/ordereddict-ordered-dictionary/#respond Fri, 11 May 2018 13:10:17 +0000 https://howtodoinjava.com/?p=10337 An OrderedDict maintains the insertion order of items added to dictionary. The order of items is preserved when iterating or serializing also. OrderedDict example To easily construct such dictionaries, you can use defaultdict in the collections module. A feature of defaultdict is that it automatically initializes the first value so you can simply focus on […]

The post Python – OrderedDict ( Ordered Dictionary ) appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/ordereddict-ordered-dictionary/feed/ 0
multidict – Map key to multiple values in dictionary https://howtodoinjava.com/python/multidict-key-to-multiple-values/ https://howtodoinjava.com/python/multidict-key-to-multiple-values/#respond Fri, 11 May 2018 12:30:09 +0000 https://howtodoinjava.com/?p=10334 ‘multidict‘ word is used to refer a dictionary where mapping a single key to multiple values is possible. e.g. Multi dictionary example To easily construct such dictionaries, you can use defaultdict in the collections module. A feature of defaultdict is that it automatically initializes the first value so you can simply focus on adding items. […]

The post multidict – Map key to multiple values in dictionary appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/multidict-key-to-multiple-values/feed/ 0
Python – Priority Queue Example https://howtodoinjava.com/python/priority-queue/ https://howtodoinjava.com/python/priority-queue/#respond Fri, 11 May 2018 11:41:52 +0000 https://howtodoinjava.com/?p=10333 Priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served […]

The post Python – Priority Queue Example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/python/priority-queue/feed/ 0