@Override
    public List<LogEntry> parseFileContents(InputStream input) throws IOException {
        if (!(input instanceof BufferedInputStream)) {
            input = new BufferedInputStream(input);
        }
        final List<LogEntry> logEntries = new ArrayList<LogEntry>();

        final byte[] data = IOUtils.toByteArray(input);
        int counter = 0;
        final Calendar currentDate = GregorianCalendar.getInstance();
        FileType fileType = FileType.UNKNOWN;

        while (counter < data.length) {
            if (fileType == FileType.DATA) {
                if (Arrays.equals(Arrays.copyOfRange(data, counter, counter + START_CODE.length), START_CODE)) {
                    counter += START_CODE.length;
                    currentDate.setTime(parseDate(Arrays.copyOfRange(data, counter, counter
                            + START_DATE_BYTES_LENGTH)));
                    counter += START_DATE_BYTES_LENGTH;
                } else if (Arrays.equals(Arrays.copyOfRange(data, counter, counter + EOF_CODE.length), EOF_CODE)) {
                    break;
                } else {
                    final byte[] dataBytes = Arrays.copyOfRange(data, counter, counter + DATA_BYTES_LENGTH);
                    final double avgVoltage = parseDouble(dataBytes[0], dataBytes[1]) / 10;
                    final double avgCurrent = parseDouble(dataBytes[2], dataBytes[3]) / 1000;
                    final double avgPowerFactor = parseDouble(dataBytes[4]) / 100;
                    final LogEntry logEntry = new LogEntryImpl();
                    logEntry.setVoltage(avgVoltage);
                    logEntry.setCurrent(avgCurrent);
                    logEntry.setPowerfactor(avgPowerFactor);
                    logEntry.setTimestamp(currentDate.getTime());
                    logEntries.add(logEntry);
                    currentDate.add(Calendar.MINUTE, 1);
                    counter += DATA_BYTES_LENGTH;
                }

            } else if (fileType == FileType.INFO) {
                LOG.warn("got INFO file - ignoring because of invalid data");
                break;
            } else if (fileType == FileType.UNKNOWN) {
                if (Arrays.equals(Arrays.copyOfRange(data, counter, counter + INFO_FILE_START_CODE.length),
                        INFO_FILE_START_CODE)) { // INFO FILE
                    fileType = FileType.INFO;
                } else if (Arrays.equals(Arrays.copyOfRange(data, counter, counter + START_CODE.length), START_CODE)) {
                    fileType = FileType.DATA;
                } else {
                    throw new RuntimeException("Unknown Filetype");
                }

            }
        }
        return logEntries;
    }