Skip to content

Commit 6339af2

Browse files
author
Mihail Slavchev
committed
bug fix
1 parent c6913dd commit 6339af2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/src/com/tns/FileSystem.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ public static String readAll(InputStream inputStream) throws IOException
5050
private final static byte[] buff = new byte[65536];
5151

5252
public static String readText(File file) throws FileNotFoundException, IOException{
53-
if (file.length() < buff.length)
53+
int fileLength = (int)file.length();
54+
if (fileLength < buff.length)
5455
{
5556
FileInputStream fis = null;
5657
try
5758
{
5859
fis = new FileInputStream(file);
59-
int length = fis.read(buff);
60+
int length = fis.read(buff, 0, fileLength);
6061
return new String(buff, 0, length);
6162
}
6263
finally

0 commit comments

Comments
 (0)