Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.00 KB | None | 0 0
  1. package splitter
  2.  
  3. import java.io.File
  4. import java.io.FileNotFoundException
  5. import java.util.*
  6.  
  7. data class RawLog(val fights : Array<RawFight>)
  8. data class RawFight(val start :Date, val end :Date, val posStart :Int, val posEnd :Int)
  9.  
  10. class LogSplitter(private val logFile :File) {
  11.  
  12.     fun findFights() {
  13.         if (!logFile.exists() or !logFile.isFile) throw FileNotFoundException("Cannot access logfile at " + logFile.absolutePath)
  14.  
  15.         val br = logFile.bufferedReader()
  16.         var currentLine = br.readLine()
  17.         var lineCounter = if (currentLine == null) 0 else 1000000
  18.         val startingTime : Long
  19.  
  20.         println("Starting").also { startingTime = System.currentTimeMillis() }
  21.  
  22.         while (currentLine != null) {
  23.             if (currentLine.contains("ENCOUNTER_START", false)) println(currentLine)
  24.  
  25.             currentLine = br.readLine().also { lineCounter++ }
  26.         }
  27.  
  28.         println("Done in " + System.currentTimeMillis().minus(startingTime).div(1000) + "s")
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement