/*
* Svjatoslav Commons - shared library of common functionality.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
*
* This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
*/
package eu.svjatoslav.commons.data;
public class EnhancedDataInputStream extends DataInputStream {
- public EnhancedDataInputStream(final InputStream in) {
- super(in);
- }
+ public EnhancedDataInputStream(final InputStream in) {
+ super(in);
+ }
- public List<Integer> readIntegerList() throws IOException {
- final int length = readInt();
+ public List<Integer> readIntegerList() throws IOException {
+ final int length = readInt();
- final List<Integer> result = new ArrayList<Integer>();
+ final List<Integer> result = new ArrayList<>();
- for (int i = 0; i < length; i++)
- result.add(readInt());
+ for (int i = 0; i < length; i++)
+ result.add(readInt());
- return result;
- }
+ return result;
+ }
- public String readString() throws IOException {
+ public String readString() throws IOException {
- final int length = readInt();
- if (length == -1)
- return null;
+ final int length = readInt();
+ if (length == -1)
+ return null;
- final byte[] bytes = new byte[length];
- readFully(bytes);
+ final byte[] bytes = new byte[length];
+ readFully(bytes);
- return new String(bytes);
- }
+ return new String(bytes, "UTF-8");
+ }
}