package Ġx de an . stackoverflow . readme Ċ Ċ import Ġio . reactivex . Flow able Ċ import Ġx de an . j ex . extra . collection . Tra verse Ċ import Ġx de an . j ex . extra . rx 2 . Rx Schedulers Ċ import Ġx de an . j ex . util . task . Task Util Ċ import Ġjava . nio . file . Files Ċ import Ġjava . nio . file . Path Ċ import Ġjava . nio . file . Paths Ċ import Ġjava . util . Arrays Ċ import Ġjava . util . Collections Ċ import Ġx de an . j ex . util . task . try to . Try Ċ import Ġio . reactivex . rx kotlin . to Flow able Ċ Ċ val ĠROOT Ġ= ĠarrayOf ( Ċĉ ĉ Paths . get (" src ", Ġ" main ", Ġ" java "), Ċĉ ĉ Paths . get (" src ", Ġ" main ", Ġ" kotlin "), Ċĉ ĉ Paths . get (" src ", Ġ" main ", Ġ" scala ")) Ċ val ĠREADME : ĠPath Ġ= ĠPaths . get (" README . md ") Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ Ċ ĉ assert ( Files . exists ( README )) Ċ ĉ val Ġscheduler Ġ= ĠRx Schedulers . fixed Size ( 1 0 ) Ċ ĉ ROOT . to Flow able () Ċĉĉ ĉ . flatMap Ġ{ Ċĉĉĉ ĉ Tra verse . pre Order Traversal < Path >( it ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ if Ġ( it . should Tra verse ) Ċĉĉĉĉĉ ĉ try Ġ{ Ċĉĉĉĉĉĉ ĉ Files . new Directory Stream ( it ) Ċĉĉĉĉĉ ĉ } Ġcatch ( e : ĠException ) Ġ{ Ċĉĉĉĉĉĉ ĉ emptyList < Path >() Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ else Ġempty List < Path >() Ċĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ . filter Ġ{ Ġit . is Question Ġ} Ċĉĉĉĉĉ ĉ . flatMap Ġ{ ĠFlow able . just ( it ). map (:: Question ). subscribe On ( scheduler ) Ġ} Ċĉĉĉĉĉ ĉ . do On Next (:: println ) Ċĉĉ ĉ } Ċĉĉ ĉ . reduce ( Read Me Writer ()) Ġ{ Ġt , Ġq Ġ-> Ġt . add ( q ) Ġ} Ċĉĉ ĉ . to Observable () Ċĉĉ ĉ . blocking ForEach Ġ{ Ġit . writeTo ( README ) Ġ} Ċ } Ċ Ċ val ĠPath . should Tra verse : ĠBoolean Ġget () Ġ= ĠFiles . isDirectory ( this ) Ġ&& Ġ! this . is Question Ċ Ċ val ĠPath . is Question : ĠBoolean Ġget () Ġ= Ġthis . fileName . toString (). matches ( Regex (" Q [ 0 - 9 ]+ ( \\. (( java )| ( kt )| ( scala ))) ? ")) ĊĊ