public byte[] contentsToByteArray(@NotNull final VirtualFile file) throws IOException {
final FileInputStream stream = new FileInputStream(convertToIOFileAndCheck(file));
try {
- return FileUtil.loadBytes(stream, (int)file.getLength());
+ final int length = (int)file.getLength();
+ assert length >= 0 : file;
+ return FileUtil.loadBytes(stream, length);
}
finally {
stream.close();
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
else {
try {
- return FileUtil.loadBytes(contentStream, (int)file.getLength());
+ final int length = (int)file.getLength();
+ assert length >= 0 : file;
+ return FileUtil.loadBytes(contentStream, length);
}
catch (IOException e) {
throw FSRecords.handleError(e);