Here you can find the source of unsignedToSigned(int[] unsignedBytes)
public static byte[] unsignedToSigned(int[] unsignedBytes)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] unsignedToSigned(int[] unsignedBytes) { byte[] signedBytes = new byte[unsignedBytes.length]; for (int i = 0; i < unsignedBytes.length; i++) { if (i < 0 || i > 255) { throw new IllegalArgumentException(String.format( "Invalid value at position %d: %d is not an unsigned 8-bit integer (between 0 and 255)", i, unsignedBytes[i])); }//from w w w.jav a 2 s. c o m signedBytes[i] = (byte) (unsignedBytes[i]); } return signedBytes; } }