AWT / CATATAN</>↗AWT10 Jun 2006
Here you see a code sample to read an image file. This code will work either the image file is located in a file folder or inside a jar file. You can use javax.imageio.ImageIO class to read the image file. package org.kodejava.awt; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; public class ReadingImage { public […]
CORE API / CATATAN</>↗Core API09 Jun 2006
package org.kodejava.network; import java.net.InetAddress; import java.net.UnknownHostException; public class HostNameExample { public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost(); System.out.println("Hostname: " + address.getHostName()); } catch (UnknownHostException e) { e.printStackTrace(); } } } An example of output produce by the code snippet above is: Hostname: Krakatau
CORE API / CATATAN</>↗Core API06 Jun 2006
The example code below helps you to get all weekday names as an array of string. The first method, getWeekdays() return the full name string while the second method getShortWeekdays() return the short name of the weekday. package org.kodejava.text; import java.text.DateFormatSymbols; public class WeekdayNames { public static void main(String[] args) { DateFormatSymbols dfs = new […]
CORE API / CATATAN</>↗Core API05 Jun 2006
The example code below helps you to get all month names as an array of String. The first method, getMonths() return the full name string while the second method getShortMonths() return the short name of the month. package org.kodejava.text; import java.text.DateFormatSymbols; import java.util.Locale; public class MonthNames { public static void main(String[] args) { String[] months […]
CORE API / CATATAN</>↗Core API02 Jun 2006
The following code snippet demonstrate how to use the Boolean.valueOf() method to convert primitive boolean value or a string into Boolean object. This method will return the corresponding Boolean object of the given primitive boolean value. When a string value is passed to this method it will return Boolean.TRUE when the string is not null, […]
CORE API / CATATAN</>↗Core API29 Mei 2006
To convert a string into boolean we can use the Boolean.parseBoolean(String) method. If we pass a non null value that equals to true, ignoring case, this method will return true value. Given other values it will return a false boolean value. package org.kodejava.lang; public class BooleanParseExample { public static void main(String[] args) { // Parsing […]