I want to read files as byte arrays and realised that amount of read bytes varies depending on the used method. Here the relevant code:

```
    public byte[] readResource() {
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(FILE_NAME)) {
        int available = is.available();
        byte[] result = new byte[available];
        is.read(result, 0, available);

        return result;
    } catch (Exception e) {
        log.error("Failed to load resource '{}'", FILE_NAME, e);
    }

    return new byte[0];
}

public byte[] readFile() {
    File file = new File(FILE_PATH + FILE_NAME);
    try (InputStream is = new FileInputStream(file)) {
        int available = is.available();
        byte[] result = new byte[available];
        is.read(result, 0, available);

        return result;
    } catch (Exception e) {
        log.error("Failed to load file '{}'", FILE_NAME, e);
    }

    return new byte[0];
}

```

Calling File.length() and reading with the FileInputStream returns the correct length of 21566 bytes for the given test file, though reading the file as a resources returns 21622 bytes. 

Does anyone know why I get different results and how to fix it so that readResource() returns the correct result?