APACHE COMMONS / CATATAN</>↗Apache Commons26 Mar 2010
The getFreeSpaceKb(String path) method in the FileSystemUtils class can help you to calculate the free space of a drive or volume in kilobytes. Beside using commons-io solution, you can use the File.getFreeSpace() method call provided in the Java 1.6 API. You can find an example of it in the following link: How do I get […]
CORE API / CATATAN</>↗Core API25 Mar 2010
This example show you how to get the printer or print service installed on your machine. To get the installed services we can use PrinterJob.lookupPrintServices() method call. This method return an array of PrintService objects. After that call PrintService.getName() method to get the print service name. package org.kodejava.print; import javax.print.PrintService; import java.awt.print.PrinterJob; public class PrinterName […]
CORE API / CATATAN</>↗Core API20 Mar 2010
If you want to clear a buffer, but you want to keep the unread data in the buffer then you need to use the compact() method of the buffer. The compact() method will copy the unread data to the beginning of the buffer and set the position right after the unread data. The limit itself […]
CORE API / CATATAN</>↗Core API18 Mar 2010
The code below show you how to clear a buffer using the clear() method call. The clear method call set the position in the buffer to 0 and limit to the capacity of the buffer. We usually call the clear() method after we read the entire content of a buffer and clear it for ready […]
CORE API / CATATAN</>↗Core API17 Mar 2010
The code below show you how to get the signum function of a number using the Math.signum() static method call. This method extracts the sign of a real number. If you have a number of x, the signum function of x is -1 if x < 0; 0 if x = 0 and 1 if […]
CORE API / CATATAN</>↗Core API17 Mar 2010
The static method Math.pow(double a, double b) can be used to raise the value specified in the a, the first argument, (the base), to the power of the value specified in b, the second argument, (the exponent). The exponent tells us how many times the base should be multiplied by itself. So, if I have […]