APACHE COMMONS / NOTES</>↗Apache Commons31 Mar 2010
Below is an example to move one directory with all its child directory and files to another directory. We can use the FileUtils.moveDirectory() method to simplify the process. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class DirectoryMove { public static void main(String[] args) { String source = "F:/Temp/source"; File srcDir = new File(source); […]
APACHE COMMONS / NOTES</>↗Apache Commons31 Mar 2010
To copy a directory with the entire child directories and files we can use a handy method provided by the Apache Commons IO FileUtils.copyDirectory(). This method accepts two parameters, the source directory and the destination directory. The source directory should be available while if the destination directory doesn’t exist, it will be created. package org.kodejava.commons.io; […]
APACHE COMMONS / NOTES</>↗Apache Commons28 Mar 2010
The code snippet below shows you how to use the FileUtils.copyURLToFile(URL, File) method of the Apache Commons IO library to help you to copy the contents of a URL directly into a file. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URL; public class URLToFile { public static void main(String[] args) { […]
JDBC / NOTES</>↗JDBC28 Mar 2010
If you want to limit the result of your query, you can call the Statement.setMaxRows(int max) method. This call will allow the ResultSet object contains a maximum number of records specified in the parameter of the setMaxRows method. Another way to limit the number of data returned in a query is to use the database-specific […]
APACHE COMMONS / NOTES</>↗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 / NOTES</>↗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 […]