CORE API / CATATAN</>↗Core API06 Jun 2007
package org.kodejava.net; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.util.List; import java.util.Map; public class HttpResponseHeaderDemo { public static void main(String[] args) { try { URL url = new URL("https://kodejava.org/index.php"); URLConnection connection = url.openConnection(); Map<String, List<String>> responseMap = connection.getHeaderFields(); for (String key : responseMap.keySet()) { System.out.print(key + " = ");...
CORE API / CATATAN</>↗Core API02 Jun 2007
package org.kodejava.net; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.nio.charset.StandardCharsets; public class URLDemo { public static void main(String[] args) { try { // Creating a url object by specifying each parameter separately, including // the protocol, hostname, port number, and the page name URL url = new URL("https", "kodejava.org", 443, "/index.php"); // We […]
CORE API / CATATAN</>↗Core API30 Mei 2007
You want to create a program that read a webpage content of a website page. The example below use the URL class to create a connection to the website. You create a new URL object and pass the URL information of a page. After the object created you can open a stream connection using the […]
APPLET / CATATAN</>↗Applet26 Mei 2007
In this applet example you’ll see how to display a message in browser status bar. To make the example a bit more interesting we’ll display the current time as the message. The time will be updated every on second during the lifetime of the applet. package org.kodejava.applet; import java.applet.Applet; import java.awt.Graphics; import java.text.DateFormat; import java.text.SimpleDateFormat; […]
CORE API / CATATAN</>↗Core API23 Mei 2007
This example demonstrates you how to remove duplicate elements from an array using the help of java.util.HashSet class. package org.kodejava.util; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class ArrayRemoveDuplicate { public static void main(String[] args) { // A string array with duplicate values. String[] data = {"A", "C", "B", "D", "A", "B", "E", […]
CORE API / CATATAN</>↗Core API22 Mei 2007
package org.kodejava.util; import java.util.*; public class ArrayToSetExample { public static void main(String[] args) { Integer[] numbers = {7, 7, 8, 9, 10, 8, 8, 9, 6, 5, 4}; // To convert an array into a java.util.Set firstly we need to convert the // array into a java.util.List using the Arrays.asList() method. With the // List […]