Recently shared snippets

Created 2 years ago by anonymous
private static String removeBetween(String string, String startChars, String endChars) {
		if(string.contains(startChars)&& string.contains(endChars)) {
			String substringAfter = StringUtils.substringAfterLast(string, startChars);
			String substringBefore = StringUtils.substringBefore(substringAfter, endChars);
			String finalStr = StringUtils.remove(string ,startChars + substringBefore+ endChars);
			string =removeBetween(finalStr, startChars, endChars);
		}
		return string;
	}
// Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
	at org.apache.pdfbox.pdmodel.PDDocument.protect(PDDocument.java:1318)
---
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 2 more

// Solution
// add dependency in your pom.xml
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.58</version>
</dependency>
public static void main(String[] args) {

		List<String> listwithnulls = new ArrayList<String>();
		listwithnulls.add("apple");
		listwithnulls.add(null);
		listwithnulls.add("mango");
		listwithnulls.add(null);
		listwithnulls.add("banana");
		System.out.println("Let's now Filter Null Elements - ");
		listwithnulls.stream().filter(value -> value != null).forEach(System.out::println);

	}
Created 2 years ago by anonymous
we have to develop something super advanced, knowledge based security measures (pin/password/pattern) will remain more secure, as while you can steal knowledge, or brute force them, you can't duplicate them.
Created 2 years ago by anonymous
ERROR :
// Setting the port in JAVA_OPTS 
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8085"

Change it to 
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999"