CORE API / NOTES</>↗Core API05 Jul 2007
java.io.DataOutputStream and java.io.DataInputStream give us the power to write and read primitive data type to a media such as file. Both of these classes have the corresponding methods to write primitive data type and to read it back. Using this class make it easier to read int, float, double data and others without needing to […]
CORE API / NOTES</>↗Core API03 Jul 2007
This is an example of using RandomAccessFile class to read and write data to a file. Using RandomAccessFile enable us to read or write to a specific location in the file at the file pointer. Imagine the file as a large array of data that have their own index. In the code below you’ll see […]
SERVLET / NOTES</>↗Servlet02 Jul 2007
package org.kodejava.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = "/request-headers") public class ServletRequestHeader extends HttpServlet implements Servlet...
SERVLET / NOTES</>↗Servlet01 Jul 2007
In the code example below we will extract information regarding the HTTP (Hypertext Transport Protocol) from the request object (HttpServletRequest). We will extract the protocol used (http / https), server name and its assigned port number. We will also read our application context path, servlet path, path info and the query string. If we combine […]
CORE API / NOTES</>↗Core API28 Jun 2007
The code below use File.mkdirs() method to create a collection of directories recursively. It will create a directory with all its necessary parent directories. package org.kodejava.io; import java.io.File; public class CreateDirs { public static void main(String[] args) { // Define a deep directory structures and create all the // directories at once. String directories = […]
BASIC / NOTES</>↗Basic28 Jun 2007
Here is an example of comparing two strings for equality without considering their case sensitivity. To do this we can use equalsIgnoreCase() method of the String class. Let’s see an example below: package org.kodejava.basic; public class EqualsIgnoreCase { public static void main(String[] args) { String uppercase = "ABCDEFGHI"; String mixed = "aBCdEFghI"; // To compare […]