minor fix

This commit is contained in:
DOHA 2016-10-29 11:37:55 +02:00
parent cf044dda80
commit 5e46e9278c
1 changed files with 4 additions and 3 deletions

View File

@ -111,11 +111,11 @@ public class JavaReadFromFileUnitTest {
@Test @Test
public void whenReadUTFEncodedFile_thenCorrect() throws IOException { public void whenReadUTFEncodedFile_thenCorrect() throws IOException {
final String expected_value = "é?’空"; final String expected_value = "青空";
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8")); final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8"));
final String currentLine = reader.readLine(); final String currentLine = reader.readLine();
reader.close(); reader.close();
System.out.println(currentLine);
assertEquals(expected_value, currentLine); assertEquals(expected_value, currentLine);
} }
@ -143,8 +143,9 @@ public class JavaReadFromFileUnitTest {
final FileChannel channel = reader.getChannel(); final FileChannel channel = reader.getChannel();
int bufferSize = 1024; int bufferSize = 1024;
if (bufferSize > channel.size()) if (bufferSize > channel.size()) {
bufferSize = (int) channel.size(); bufferSize = (int) channel.size();
}
final ByteBuffer buff = ByteBuffer.allocate(bufferSize); final ByteBuffer buff = ByteBuffer.allocate(bufferSize);
channel.read(buff); channel.read(buff);
buff.flip(); buff.flip();