CORE API / CATATAN</>↗Core API14 Jul 2006
To determine if an abstract pathname is a directory we can use the File.isDirectory() method. Here is an example code. package org.kodejava.io; import java.io.File; public class IsDirectoryExample { public static void main(String[] args) { // Creates a instance of File. File file = new File("C:/Users/wsaryada"); // Check if the abstract pathname is a directory by […]
CORE API / CATATAN</>↗Core API13 Jul 2006
package org.kodejava.io; import java.io.File; public class FreeSpaceExample { public static void main(String[] args) { // We create an instance of a File to represent a partition // of our file system. For instance here we used a drive D: // as in Windows operating system. File file = new File("D:"); // Using the getTotalSpace() we […]
CORE API / CATATAN</>↗Core API08 Jul 2006
package org.kodejava.io; import java.io.File; import java.io.IOException; public class FileRenameExample { public static void main(String[] args) throws IOException { // Creates a new file called OldHouses.csv File oldFile = new File("OldHouses.csv"); boolean created = oldFile.createNewFile(); System.out.println("File created? " + created); // Creates the target file. File newFile = new File("NewHouses.csv"); // The renameTo() method renames file […]
CORE API / CATATAN</>↗Core API05 Jul 2006
The File.isHidded() method checks to see if the file represented by aFile object is a hidden file. The definition of hidden is varied between operating systems. On UNIX based systems, a file is considered to be hidden when their name begins with a period character ('.'). On Windows operating system, a file is considered to […]
CORE API / CATATAN</>↗Core API02 Jul 2006
In this example you’ll see how to read the list of files inside a directory. To get this functionality we can use the File.listFiles() method. This method return an array of File object which can be either an instance of file or directory. package org.kodejava.io; import java.io.File; import java.io.FilenameFilter; public class DirectoryContentExample { public static […]
CORE API / CATATAN</>↗Core API27 Jun 2006
We create a directory by calling mkdir() method of the File object. This method returns true if and only if the directory was successfully created. If false was returned, no directory is created. This could be caused, for example that the directory was already exists. package org.kodejava.io; import java.io.File; public class CreateDirectoryExample { public static […]