AWT / CATATAN</>↗AWT28 Des 2009
The code below show you how to activate the Caps Lock button programmatically. Setting the locking state to Boolean.TRUE will turn the Caps Lock on. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class TurnCapsLockOn { public static void main(String[] args) throws Exception { // Gets the default toolkit. Toolkit toolkit = Toolkit.getDefaultToolkit(); // Update the […]
AWT / CATATAN</>↗AWT26 Des 2009
This example show you how to detect if the Scroll Lock key is in active mode. If you run the program you will get an output telling you that the Scroll Lock button is active or not active. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class ScrollLockState { public static void main(String[] args) { Toolkit […]
AWT / CATATAN</>↗AWT25 Des 2009
This example show you how to detect if the Num Lock key is in active mode. If you run the program you will get an output telling you that the Num Lock button is active or not active. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class NumLockState { public static void main(String[] args) { Toolkit […]
AWT / CATATAN</>↗AWT23 Des 2009
This example show you how to detect if the Caps Lock key is in active mode. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class CapsLockState { public static void main(String[] args) { // Get the locking state of the Caps Lock button. This method // return boolean true value if it is "on". boolean isOn […]
CORE API / CATATAN</>↗Core API22 Des 2009
package org.kodejava.io; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class ReadFileIntoByteArray { public static void main(String[] args) throws IOException { File file = new File("README.md"); try (InputStream is = new FileInputStream(file)) { if (file.length() > Integer.MAX_VALUE) { throw new IOException("File is too large."); } int offset = 0; int bytesRead; byte[] bytes = […]
APACHE COMMONS / CATATAN</>↗Apache Commons22 Des 2009
The code below show you how to use the Apache Commons-Lang RandomStringUtils class to generate some random string data. package org.kodejava.commons.lang; import org.apache.commons.lang3.RandomStringUtils; public class RandomStringUtilsDemo { public static void main(String[] args) { // Creates a 64-chars length random string of number. String result = RandomStringUtils.random(64, false, true); System.out.println("random = " + result); // Creates […]