This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.net.URISyntaxException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.security.KeyFactory; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.PrivateKey; | |
import java.security.interfaces.RSAPublicKey; | |
import java.security.spec.InvalidKeySpecException; | |
import java.security.spec.PKCS8EncodedKeySpec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void createTarGzipFiles(List<Path> files, Path output) { | |
try (OutputStream fOut = Files.newOutputStream(output); | |
BufferedOutputStream buffOut = new BufferedOutputStream(fOut); | |
GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(buffOut); | |
TarArchiveOutputStream tOut = new TarArchiveOutputStream(gzOut)) { | |
for (Path path : Collections.unmodifiableList(files)) { | |
if (!Files.isRegularFile(path)) { | |
throw new IOException("Support only file!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws InterruptedException { | |
var start = Instant.now(); | |
verySlow(); | |
var end= Duration.between(start,Instant.now()).toMillis(); | |
System.out.printf("Time Taken: %dms%n",end); | |
} | |
private static void verySlow() throws InterruptedException { | |
Thread.sleep(1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
var task = new TimerTask() { | |
@Override | |
public void run() { | |
System.out.println("run some task"); | |
} | |
}; | |
var timeer = new Timer(); | |
timeer.scheduleAtFixedRate(task, 10, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
System.Logger logger = System.getLogger("Apps"); | |
logger.log(System.Logger.Level.ERROR, "some log"); | |
logger.log(System.Logger.Level.INFO, "some info"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#exit on error | |
set -B | |
rm *.jks 2> /dev/null | |
rm *.pem 2> /dev/null | |
echo "====================================================" | |
echo "Creating fake third-party chain root -> ca" |