I'm trying to re-factor a large and frequently used part of my application into separate methods to make it easier to maintain.
Some of these methods asks the user for input and does input validation, so I've used a Scanner and System.in
But when I close my Scanner I also close System.in
So my question is, can I only prevent System.in being closed by shielding it with CloseShieldInputStream or should I just start passing a Scanner to the methods?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…