Skip to content

Instantly share code, notes, and snippets.

@gizemabali
Last active March 14, 2019 11:15
Show Gist options
  • Save gizemabali/9eb4bc48cbaae687599a4919feb6f1f8 to your computer and use it in GitHub Desktop.
Save gizemabali/9eb4bc48cbaae687599a4919feb6f1f8 to your computer and use it in GitHub Desktop.
JAVA - read from a tar.gz file
// File consists of json objects
FileInputStream inputStream = null;
Scanner sc = null;
try {
inputStream = new FileInputStream(file_path);
sc = new Scanner(inputStream, "UTF-8");
while (sc.hasNextLine()) {
String line = sc.nextLine();
JsonObject json = new JsonParser().parse(line).getAsJsonObject();
//...
}
inputStream.close();
sc.close();
} catch (Exception e) {
logger.error("Error occured while indexing observations dump file.", e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment