APPLET / CATATAN</>↗Applet10 Apr 2010
To display an image in an applet we first need to obtain the image object itself. A call to applet’s getImage(URL url, String name) method help us to create an image object from the specified URL of the image. For displaying the image on the applet’s screen we draw it in the paint() method using […]
APPLET / CATATAN</>↗Applet05 Apr 2010
The code snippet below show you how to get the URL of the document (HTML, JSP, etc.) where the Applet is embedded. To obtain this document URL we use the getDocumentBase() method call provided by the Applet class. In the paint() method below we use the getDocumentBase() to create a URL as a link to […]
APACHE COMMONS / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 […]