String fileData = null;
if (tFile == null) {
throw new FileDoesNotExistException(path.toString());
}
if (tFile.isComplete()) {
InStream is = tFile.getInStream(ReadType.NO_CACHE);
try {
int len = (int) Math.min(5 * Constants.KB, tFile.length() - offset);
byte[] data = new byte[len];
long skipped = is.skip(offset);
if (skipped < 0) {
// nothing was skipped
fileData = "Unable to traverse to offset; is file empty?";
} else if (skipped < offset) {
// couldn't skip all the way to offset
fileData = "Unable to traverse to offset; is offset larger than the file?";
} else {
// read may not read up to len, so only convert what was read
int read = is.read(data, 0, len);
if (read < 0) {
// stream couldn't read anything, skip went to EOF?
fileData = "Unable to read file";
} else {
fileData = CommonUtils.convertByteArrayToStringWithoutEscape(data, 0, read);
if (fileData == null) {
fileData = "The requested file is not completely encoded in ascii";
}
}
}
} finally {
is.close();
}
} else {
fileData = "The requested file is not complete yet.";
}
try {