Skip to content

Instantly share code, notes, and snippets.

public class StopThread {
private static volatile boolean stopRequested;
public static void main(String[] args)
throws InterruptedException {
Thread backgroundThread = new Thread(new Runnable() {
public void run() {
int i = 0;
while (!stopRequested)
i++;
}
public class StopThread {
private static boolean stopRequested;
private static synchronized void requestStop() {
stopRequested = true;
}
private static synchronized boolean stopRequested() {
return stopRequested;
}
public static void main(String[] args)
throws InterruptedException {
public class StopThread {
private static boolean stopRequested;
public static void main(String[] args)
throws InterruptedException {
Thread backgroundThread = new Thread(new Runnable() {
public void run() {
int i = 0;
while (!stopRequested)
i++;
}
List<User> usersList = Arrays.asList(
new User("Alice", "Darvin", 28),
new User("Bob", "Cooper", 35),
new User("Jessika", "Davies", 18),
new User("Albert ", "Downing", 58),
new User("Luke", "Morgan", 23)
);
package com.sample.streams;
public class User {
private String firstName;
private String lastName;
private Integer age;
public User(String firstName, String lastName, Integer age) {
this.firstName = firstName;
import java.util.function.Consumer;
public class Main {
public static void main(String[] args) {
Consumer<String> lambda = s1 -> System.out.println("Hi " + s1);
lambda.accept("Alice"); //Output : "Hi Alice"
}
import com.lambdaSample.SampleFunctionalInterface;
public class Main {
public static void main(String[] args) {
SampleFunctionalInterface lambda = s1 -> System.out.println("Hi " + s1);
lambda.foo("Alice"); //Output : "Hi Alice"
}
import java.util.function.Function;
public class Main {
public static void main(String[] args) {
Function<String, Integer> lambda = a -> a.length();
System.out.println(lambda.apply("MyString"));
}
public static void uploadToFTP(MultipartFile file, String baseDirectory, String scanDirectory)
throws ScanManagerException {
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect("host","port");
client.login("username","password");
if (client.isConnected()) {
boolean directoryExists = client.changeWorkingDirectory(baseDirectory + File.separator +
*** ECDH ServerKeyExchange
Signature Algorithm SHA256withRSA
Server key: Sun EC public key, 256 bits
public x coord: 49880139518100326927648337356136531406906846853753693344570844017045565963249
public y coord: 95714017526253024568876509155195989984116809887282783483716821451591048546410
parameters: secp256r1 [NIST P-256, X9.62 prime256v1] (1.2.840.10045.3.1.7)