一段java代码求转化成OC代码 急急急
public static String decrypt(String fileUrl, int keyLength)
throws Exception {
File file = new File(fileUrl);
if (!file.exists()) {
return null;
}
InputStream is = new FileInputStream(fileUrl);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
byte[] buffer2 = new byte[1024];
byte bMax = (byte) 255;
long size = file.length() - keyLength;
int mod = (int) (size % 1024);
int div = (int) (size >> 10);
int count = mod == 0 ? div : (div + 1);
int k = 1, r;
r = is.read(buffer);
while ((k <= count && (r = is.read(buffer)) > 0)) {
if (mod != 0 && k == count) {
r = mod;
}
for (int i = 0; i < r; i++) {
byte b = buffer[i];
buffer2[i] = b == 0 ? bMax : --b;
}
out.write(buffer2, 0, r);
k++;
}
out.close();
is.close();
return new String(out.toByteArray());
}