REGEX / CATATAN</>↗Regex18 Mar 2013
The code snippet below remove the characters from a string that is not inside the range of x20 and x7E ASCII code. The regex below strips non-printable and control characters. But it also keeps the linefeed character n (x0A) and the carriage return r (x0D) characters. package org.kodejava.regex; public class ReplaceNonAscii { public static void […]
SECURITY / CATATAN</>↗Security11 Mar 2013
In this example we will learn how to verify the digital signature of the previously signed data. To sign the data you can see the previous example on this post How to create a digital signature and sign data?. Here the code snippet: package org.kodejava.security; import java.nio.file.Files; import java.nio.file.Paths; import java.security.KeyFactory; import java.security.PublicKey; import java.security.Signature; […]
CORE API / CATATAN</>↗Core API06 Mar 2013
The following code snippet will show you how to split a string by numbers of characters. We create a method called splitToNChars() that takes two arguments. The first arguments is the string to be split and the second arguments is the split size. This splitToNChars() method will split the string in a for loop. First […]
SECURITY / CATATAN</>↗Security06 Mar 2013
In the following code snippet you will learn how to generate a digital signature to sign a data or file. To create a signature we will need a key pair of public and private key. But for the signing process we’ll only use the private key, while the public key will be used to verify […]
SECURITY / CATATAN</>↗Security05 Mar 2013
The code snippet below show you how to use the JDK Security API to generate public and private keys. A private key can be used to sign a document and the public key is used to verify that the signature of the document is valid. The API we used to generate the key pairs is […]
CORE API / CATATAN</>↗Core API05 Mar 2013
To eliminate redundant elements from a Path we can use the Path.normalize() method. For example in the following code snippet. When try accessing the README file in the current directory the . symbol in the Path elements considered to be redundant, we don’t need it. That’s why we normalize the Path. package org.kodejava.io; import java.nio.file.Path; […]