if (length > CP_BUF_SIZE) { length = CP_BUF_SIZE;
int bufferSize; if (length > BUF_SIZE) { bufferSize = BUF_SIZE; } else { bufferSize = length;
	private static void cp(File from, File to, int truncateSize) throws IOException {		FileInputStream in = null;		FileOutputStream out = null;		try {			out = new FileOutputStream(to);			int length = (int) from.length();			if (truncateSize > length)				length = 0;			else				length -= truncateSize;			if (length > 0) {				if (length > CP_BUF_SIZE) {					length = CP_BUF_SIZE;				}				in = new FileInputStream(from);				byte buffer[] = new byte[length];				int size = 0;				int count;				while ((count = in.read(buffer, 0, length)) > 0) {					if ((size + count) >= length)						count = length - size;					out.write(buffer, 0, count);					size += count;				}				in.close();				in = null;			}			out.close();			out = null;		} catch (IOException e) {			// close open streams			if (out != null) {				try {					out.close();				} catch (IOException ee) {				}			}			if (in != null) {				try {					in.close();				} catch (IOException ee) {				}			}			throw e;		}	}