CORE API / CATATAN</>↗Core API11 Jan 2007
package org.kodejava.text; import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class IterateSubstringExample { private static final String text = "How razorback-jumping frogs can level six piqued gymnasts"; public static void main(String[] args) { CharacterIterator it = new StringCharacterIterator(text, 4, 27, 5); // In this loop we just iterator a subset of character defined in the // StringCharacterIterator above. […]
CORE API / CATATAN</>↗Core API08 Jan 2007
In this example we use the java.text.CharacterIterator implementation class java.text.StringCharacterIterator to reverse a string. It’s done by reading a string from the last index up to the beginning of the string. package org.kodejava.text; import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class StringCharacterIteratorReverseExample { private static final String text = "Jackdaws love my big sphinx of quartz"; public […]
CORE API / CATATAN</>↗Core API05 Jan 2007
The following example show you how to iterate each character of a string using the java.text.CharacterIterator and java.text.StringCharacterIterator to count the number of vowels and consonants in the string. package org.kodejava.text; import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class StringCharacterIteratorExample { private static final String text = "The quick brown fox jumps over the lazy dog"; public […]
JDBC / CATATAN</>↗JDBC01 Jan 2007
The code snippet below shows you how to disable auto-commit operation when executing JDBC commands or queries. package org.kodejava.jdbc; import java.sql.*; public class AutoCommitSettingExample { private static final String URL = "jdbc:mysql://localhost/kodejava"; private static final String USERNAME = "kodejava"; private static final String PASSWORD = "s3cr*t"; public static void main(String[] args) { // DO: Get […]
SERVLET / CATATAN</>↗Servlet28 Des 2006
This example show you how to read a text file in a servlet. Using the ServletContext.getResourceAsStream() method will enable you to read a file whether the web application is deployed in an exploded format or in a war file archive. The following servlet read the configuration.properties file from the /WEB-INF directory in our web application. […]
CORE API / CATATAN</>↗Core API28 Des 2006
This example show you how to create a simple class for scheduling a task using Timer and TimerTask class. package org.kodejava.util; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TimerExample extends TimerTask { private final DateFormat formatter = new SimpleDateFormat("hh:mm:ss a"); public static void main(String[] args) { // Create an instance […]