SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

CORE API / NOTES</>↗
Core API25 Feb 2010

How do I get the absolute value of a number?

The example below show you how to get the absolute value of a number. To get the absolute value or the abs value of a number we use the Math.abs() method call. The Math.abs() method is an overloaded that can accept value in type of double, float, int or long. package org.kodejava.math; public class GetAbsoluteValueExample […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API25 Feb 2010

How do I read data from a buffer into channel?

In this example you’ll see how to read data from buffer using FileChannel.write() method call. Reading from a buffer means that you are writing data into the channel object. In the snippet below the data from our dummy buffer will be read and written into the result.txt file. package org.kodejava.io; import java.io.File; import java.io.FileOutputStream; import […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API23 Feb 2010

How do I change the buffer mode between write and read?

A buffer can be read or written. To change the mode between the write mode and read mode we use the flip() method call on the buffer. There are few things that you should know when you change between the write mode to the read mode. A buffer have the capacity, position and limit properties. […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API22 Feb 2010

How do I write data into ByteBuffer using put method?

The snippet below show you how to write some bytes into the java.nio.ByteBuffer object through a call to the put() method. package org.kodejava.io; import java.nio.ByteBuffer; public class BufferPut { public static void main(String[] args) { ByteBuffer buffer = ByteBuffer.allocate(32); buffer.put((byte) 65); buffer.put((byte) 66); buffer.put((byte) 67); buffer.put((byte) 68); buffer.put((byte) 69); // Writes a sequence of bytes […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API18 Feb 2010

How do I use a FileChannel to read data into a Buffer?

The example below show how to use a FileChannel to read some data into a Buffer. We create a FileChannel from a FileInputStream instance. Because a channel reads data into buffer we need to create a ByteBuffer and set its capacity. Read data from a channel into buffer using the FileChannel.read() method. To read out […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API16 Feb 2010

How do I create a NIO Buffer?

This post show you how to use the java.nio buffer such as ByteBuffer, CharBuffer, DoubleBuffer, etc. To create a buffer you can use the allocate(int capacity) method. Each buffer object has the allocate(int capacity) method. You need to pass the value of the capacity of the buffer to be created when calling this method. package […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.