By the way, the "Scala" way to do this may just be
```scala
Try(cls.getMethod("hflush")).getOrElse(cls.getMethod("sync"))
```