CORE API / NOTES</>↗Core API30 Mar 2013
In the following code snippet you will learn how to move a file using the java.nio.file.Files helper class of JDK 7. This class simplify how you can move file. To move file you need to define the Path of the source and the target file. We use the Files.move() method to move the file by […]
CORE API / NOTES</>↗Core API25 Mar 2013
In this example we are going to learn to use the DirectoryStream, which part of java.nio.file package, to find files in a directory. We begin by creating a Path, the directory where the search will be conducted. After that we create a DirectoryStream using Files.newDirectoryStream(). To create a directory stream we passed two arguments, the […]
CORE API / NOTES</>↗Core API24 Mar 2013
In this example you’ll learn how to create and delete a file. Using the new Files class helper from the JDK 7 you can create a file using the Files.createFile(Path) method. To delete a file you can use the Files.delete(Path) method. Before create a file and delete a file we can check to see if […]
CORE API / NOTES</>↗Core API23 Mar 2013
In this example you’ll learn how to use the Files.walkFileTree() to walk through file tree. This method requires two parameters. The first parameter is the starting file, in this example we’ll start from drive F:/Temp. And the second parameter is the file visitor to invoke for each file. Here we’ll create a file visitor call […]
REGEX / NOTES</>↗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 / NOTES</>↗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; […]