CORE API / NOTES</>↗Core API05 Dec 2012
In this example you’ll learn how to clear or reset the content of an array. We can use the java.util.Arrays.fill() method to replace to content of each element in the array. In the example below we create two arrays, names and numbers array. We initialize these arrays with some values and then clear the value […]
CORE API / NOTES</>↗Core API05 Dec 2012
This example show you how to validate input when using java.util.Scanner. To validate input the Scanner class provides some hasNextXXX() method that can be use to validate input. For example if we want to check whether the input is a valid integer we can use the hasNextInt() method. In the code snippet below will demonstrate […]
CORE API / NOTES</>↗Core API04 Dec 2012
This example show you how to use the DosFileAttributes class to get file attribute that support DOS file system. This class extends the BasicFileAttributes class. Using the DosFileAttributes class we can read file attributes using isArchive(), isHidden(), isReadOnly() and isSystem() methods. Let’s see the code snippet below: package org.kodejava.io; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; […]
CORE API / NOTES</>↗Core API04 Dec 2012
This code snippet show you an example on how to set the value of file attributes. Here we will set the DosFileAttributes. To set the value of file attributes we use the Files.setAttributes() method. To set DosFileAttributes we can use the following attributes: "dos:archive", "dos:hidden", "dos:readonly" and "dos:system". For details let’s see the code snippet […]
CORE API / NOTES</>↗Core API04 Dec 2012
In JDK 7 we can write all lines from a List of String into a file using the Files.write() method. We need to provide the Path of the file we want to write to, the List of strings and the charsets. Each line is a char sequence and is written to the file in sequence […]
CORE API / NOTES</>↗Core API30 Nov 2012
This example you’ll learn how to get file’s basic attributes. Basic file attributes are attributes that are common to many file systems and consist of mandatory and optional file attributes as defined by the BasicFileAttributes interface. The file’s basic attributes include file’s date time information such as the creation time, last access time, last modified […]