CORE API / CATATAN</>↗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 / CATATAN</>↗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 […]
CORE API / CATATAN</>↗Core API20 Jun 2006
In this example you will learn how to convert decimal number to binary number. To convert decimal number to binary we can use Integer.toBinaryString() method. This method takes a single parameter of integer and return a string that represent the equal binary number. If you want to convert the other way around, from binary string […]
CORE API / CATATAN</>↗Core API19 Jun 2006
This example will show you how to get the size of a file. To obtain the size of a file you can use the File‘s length() method. The length() method return the file size in bytes. package org.kodejava.io; import java.io.File; public class FileSize { public static void main(String[] args) { File file = new File("README.md"); […]
CORE API / CATATAN</>↗Core API15 Jun 2006
To get file last modification date we can use the lastModified() method of the File class. This method returns a long value. After getting this value you can create an instance of java.util.Date class and pass this value as the parameter. This Date will hold the file’s last modification date. package org.kodejava.io; import java.io.File; import […]
CORE API / CATATAN</>↗Core API11 Jun 2006
To convert decimal number (base 10) to hexadecimal number (base 16) we can use the Integer.toHexString() method. This method takes an integer as parameter and return a string that represent the number in hexadecimal. To convert back the number from hexadecimal to decimal number we can use the Integer.parseInt() method. This method takes two argument, […]