Here you can find the source of toIntArray(long[] in)
Parameter | Description |
---|---|
in | a parameter |
public static int[] toIntArray(long[] in)
//package com.java2s; /*-//from w w w .jav a 2s . c o m * Copyright 2015 Diamond Light Source Ltd. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ public class Main { /** * Convert long array to integer array * @param in * @return integer array */ public static int[] toIntArray(long[] in) { int[] out = new int[in.length]; for (int i = 0; i < out.length; i++) { long value = in[i]; if (value == Long.MAX_VALUE) { value = -1; // stopgap fix for incorrectly written maximum shape } if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) { throw new IllegalArgumentException("Cannot convert to int array without data loss"); } out[i] = (int) value; } return out; } }