SergOmarov

Untitled

Sep 5th, 2017
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def specifedLoadFromFile[T](filePath:File)(implicit tag:ClassTag[T]): T = {
  2.     try {
  3.       val oos = new ObjectInputStream(new FileInputStream(filePath))
  4.       val data = oos.readObject.asInstanceOf[T]
  5.       oos.close()
  6.       data
  7.     } catch {
  8.       case e: Exception => new T()//Типо ,если не могли прочитать из файла, то создадим пустую
  9.     }
  10.   }
RAW Paste Data