CORE API / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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; […]
CORE API / NOTES</>↗Core API27 Feb 2013
The java.nio.Path provides some methods to obtain information about the Path. For example, you can get information about the file name, the parent and the root path. For these you can call the getFileName(), getParent() and getRoot() method respectively. You can also get the number of elements that make up this Path using the getNameCount() […]
CORE API / NOTES</>↗Core API26 Feb 2013
The following code snippet show you how to create a Path. A Path (java.nio.Path) in an interface that represent a location in a file system, such as C:/Windows/System32 or /usr/bin. To create a Path we can use the java.nio.Paths.get(String first, String… more) methods. Below you can see how to create a Path by passing only […]