Я написал этот код для чтения данных:
Код: Выделить всё
public class QuickDrawReader {
public static void unpackDrawing(InputStream inputStream) throws IOException {
DataInputStream dataInputStream = new DataInputStream(inputStream);
long keyId = dataInputStream.readLong();
System.out.println("keyId: " + keyId);
byte[] countryCodeBytes = new byte[2];
dataInputStream.readFully(countryCodeBytes);
String countryCode = new String(countryCodeBytes, "UTF-8");
System.out.println("CountryCode: " + countryCode);
byte recognized = dataInputStream.readByte();
System.out.println("Recognized: " + recognized);
int timestamp = dataInputStream.readInt();
System.out.println("Timestamp: " + timestamp);
int nStrokes = dataInputStream.readUnsignedShort();
System.out.println("NStrokes: " + nStrokes);
List image = new ArrayList();
// How do I populate the image List???
}
public static void unpackDrawings(String filename) throws IOException {
try (FileInputStream fileInputStream = new FileInputStream(filename)) {
while (true) {
try {
unpackDrawing(fileInputStream);
} catch (EOFException e) {
break;
}
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... es-in-java
Мобильная версия