CORE API / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 […]
CORE API / NOTES</>↗Core API27 Jun 2006
The following code snippet shows you how to get the absolute path of a file. To do this we use the java.io.File object getAbsolutePath() method. package org.kodejava.io; import java.io.File; public class AbsolutePathExample { public static void main(String[] args) { // Create an instance of File called file. File file = new File("README.md"); // Now we […]
CORE API / NOTES</>↗Core API25 Jun 2006
From the code snippet below you will learn how to convert decimal to an octal string and converting back from a string of octal number to decimal. For the first conversion we can utilize the Integer.toOctalString() method. This method takes an integer number and will return the string that represent the corresponding octal number. To […]