Package ch.akuhn.io.chunks

Source Code of ch.akuhn.io.chunks.Chunks

package ch.akuhn.io.chunks;

import java.nio.ByteBuffer;

public class Chunks {

  public static final int NULL = 0;
 
  public static final int makeName(String mnemonic) {
    ByteBuffer buffer = ByteBuffer.allocate(4);
    for (int n = 0; n < buffer.limit(); n++)
      buffer.put(characterOrSpace(mnemonic, n));
    buffer.rewind();
    return buffer.asIntBuffer().get();
  }

  private static byte characterOrSpace(String mnemonic, int n) {
    return (byte) (n < mnemonic.length() ? mnemonic.charAt(n) : ' ');
  }
 
}
TOP

Related Classes of ch.akuhn.io.chunks.Chunks

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.