Lambda Expressions best Practices Example

Lambda Expressions best Practices Example

Permutation of String in Java Algorithm

Covert String to byte array

We can use String class getBytes() method to encode the string into a sequence of bytes using the platform’s default charset. This method is overloaded and we can also pass Charset as argument.
Here is a simple program showing how to convert String to byte array in java.

Ignore case while find query using Mongodb.

Use This Criteria

How to add CORS with Spring?

1st Example For All Location

2nd Example For Validate which location and which method to allow

How To Register Multiple Interceptor In Spring MVC?

Create Configuration Class extends with WebMvcConfigurerAdapter

Log4j Multiple Appender Simple Example in java

# Root logger option
log4j.rootLogger=INFO, DEBUG, file,console

# Console Appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Append=true
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-ddHH:mm:ss,SSS} %-5p [ %M ] ( %C ) %c{1}:%L - %m%n

# File Appender
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH-mm
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-ddHH:mm:ss,SSS} %-5p [ %M ] ( %C ) %c{1}:%L - %m%n
log4j.appender.file.File=C:/log/SpringMain.log
log4j.appender.file.MaxBackupIndex=10

Provide time zone to Spring @Scheduled or XML?

Preferred Java way to ping an HTTP URL for availability

Convert Date/Time for given Timezone – java