CharBuffer order() methods in Java with Examples Last Updated : 20 Oct, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The order() method of java.nio.CharBuffer class is used to retrieve this buffer's byte order. The byte order of a char buffer created by allocation or by wrapping an existing char array is the native order of the underlying hardware. The byte order of a char buffer created as a view of a byte buffer is that of the byte buffer at the moment that the view is created.Syntax: public abstract ByteOrder order() Return Value: This method returns this buffer's byte order.Below are the examples to illustrate the order() method:Examples 1: Java // Java program to demonstrate // order() method import java.nio.*; import java.util.*; public class GFG { public static void main(String[] args) { // creating object of CharBuffer // and allocating size capacity CharBuffer cb = CharBuffer.allocate(4); // append the int value in the charbuffer cb.append('a') .append('b') .append('c') .append('d'); // rewind the Bytebuffer cb.rewind(); // Retrieve the ByteOrder // using order() method ByteOrder order = cb.order(); // print the char buffer and order System.out.println("CharBuffer is : " + Arrays.toString(cb.array()) + "\nOrder: " + order); } } Output: CharBuffer is : [a, b, c, d] Order: LITTLE_ENDIAN Examples 2: Java // Java program to demonstrate // order() method import java.nio.*; import java.util.*; public class GFG { public static void main(String[] args) { // creating object of CharBuffer // and allocating size capacity CharBuffer cb = CharBuffer.allocate(4); // Retrieve the ByteOrder // using order() method ByteOrder order = cb.order(); // print the char buffer and order System.out.println("CharBuffer is : " + Arrays.toString(cb.array()) + "\nOrder: " + order); } } Output: CharBuffer is : [,,, ] Order: LITTLE_ENDIAN Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/CharBuffer.html#order-- Comment More infoAdvertise with us Next Article CharBuffer read() methods in Java with Examples R rohitprasad3 Follow Improve Article Tags : Java Java-Functions Java-CharBuffer Java-NIO package Practice Tags : Java Similar Reads CharBuffer read() methods in Java with Examples The read() method of java.nio.CharBuffer Class is used to read characters into the specified character buffer. The buffer is used as a repository of characters as-is: the only changes made are the results of a put operation. No flipping or rewinding of the buffer is performed. Syntax: public int rea 4 min read Reader read(CharBuffer) method in Java with Examples The read(CharBuffer) method of Reader Class in Java is used to read the specified characters into a CharBuffer instance. This method blocks the stream till: It has taken some input from the stream. Some IOException has occurred It has reached the end of the stream while reading. Syntax: public int r 2 min read ByteBuffer order() method in Java with Examples order() The order() method of java.nio.ByteBuffer class is used to retrieve this buffer's byte order. The byte order is used when reading or writing multibyte values, and when creating buffers that are views of this byte buffer. The order of a newly-created byte buffer is always BIG_ENDIAN. Syntax: 4 min read DoubleBuffer order() methods in Java with Examples The order() method of java.nio.DoubleBuffer class is used to get the ByteOrder of this DoubleBuffer instance. Syntax: public abstract ByteOrder order() Return Value: This method returns this buffer's byte order.Below are the examples to illustrate the order() method:Examples 1: Java // Java program 2 min read CharBuffer position() methods in Java with Examples The position(int newPosition) method of java.nio.CharBuffer Class is used to set this buffer's position. If the mark is defined and larger than the new position then it is discarded. Syntax: public CharBuffer position(int newPosition) Parameters: This method takes the newPosition as parameter which 2 min read CharBuffer flip() methods in Java with Examples The flip() method of java.nio.CharBuffer Class is used to flip this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded. After a sequence of channel-read or put operations, invoke this method to prepare for a sequence of 2 min read Like