Java Byte Array Create toByteArray(double[][] array)

Here you can find the source of toByteArray(double[][] array)

Description

to Byte Array

License

Open Source License

Declaration

public static byte[][] toByteArray(double[][] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[][] toByteArray(double[][] array) {
        int nr = array.length;
        int nc = array[0].length;
        byte[][] ret = new byte[nr][nc];
        for (int i = 0; i < nr; i++) {
            for (int j = 0; j < nc; j++) {
                ret[i][j] = (byte) array[i][j];
            }//from   ww  w .  jav  a2  s  .com
        }
        return ret;
    }

    public static byte[][] toByteArray(float[][] array) {
        int nr = array.length;
        int nc = array[0].length;
        byte[][] ret = new byte[nr][nc];
        for (int i = 0; i < nr; i++) {
            for (int j = 0; j < nc; j++) {
                ret[i][j] = (byte) array[i][j];
            }
        }
        return ret;
    }

    public static byte[][] toByteArray(int[][] array) {
        int nr = array.length;
        int nc = array[0].length;
        byte[][] ret = new byte[nr][nc];
        for (int i = 0; i < nr; i++) {
            for (int j = 0; j < nc; j++) {
                ret[i][j] = (byte) array[i][j];
            }
        }
        return ret;
    }

    public static byte[][] toByteArray(long[][] array) {
        int nr = array.length;
        int nc = array[0].length;
        byte[][] ret = new byte[nr][nc];
        for (int i = 0; i < nr; i++) {
            for (int j = 0; j < nc; j++) {
                ret[i][j] = (byte) array[i][j];
            }
        }
        return ret;
    }

    public static byte[][] toByteArray(short[][] array) {
        int nr = array.length;
        int nc = array[0].length;
        byte[][] ret = new byte[nr][nc];
        for (int i = 0; i < nr; i++) {
            for (int j = 0; j < nc; j++) {
                ret[i][j] = (byte) array[i][j];
            }
        }
        return ret;
    }

    public static byte[][] toByteArray(String[][] array) {
        int nr = array.length;
        int nc = array[0].length;
        byte[][] ret = new byte[nr][nc];
        for (int i = 0; i < nr; i++) {
            for (int j = 0; j < nc; j++) {
                ret[i][j] = Byte.parseByte(array[i][j]);
            }
        }
        return ret;
    }
}

Related

  1. toByteArray(char[] charArray)
  2. toByteArray(char[] chars)
  3. toByteArray(char[] chars)
  4. toByteArray(char[] src)
  5. toByteArray(CharSequence hexString)
  6. toByteArray(final byte[] bytes)
  7. toByteArray(final byte[][] array)
  8. toByteArray(final char[] array)
  9. toByteArray(final char[] array)