Skip to content

Instantly share code, notes, and snippets.

@kasramp
Last active April 7, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasramp/2f6b7965c096fa7c98987b6a7e9f9848 to your computer and use it in GitHub Desktop.
Save kasramp/2f6b7965c096fa7c98987b6a7e9f9848 to your computer and use it in GitHub Desktop.
import com.fasterxml.jackson.module.kotlin.readValue
val file = Files.createTempFile("students", ".json").toFile()
var pageNumber = 0
val studentsFileContent = objectMapper.readValue<List<Student>>(file).toMutableList()
do {
val result = getStudentsDetailsByPage(pageNumber)
studentsFileContent.addAll(result)
pageNumber += 1
} while (result.hasNext())
objectMapper.writeValue(file, studentsFileContent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment