JAVA#標準輸入輸出——大小寫轉換練習'札記
阿新 • • 發佈:2019-01-11
public class TestotherStream { public static void main(String[] args) { BufferedReader br=null; try{ InputStream is=System.in; InputStreamReader isr=new InputStreamReader(is); br=new BufferedReader(isr); System.out.println("請輸入字串:"); String str; while(true) { str=br.readLine(); if (str.equalsIgnoreCase("e") || str.equalsIgnoreCase("exit")) { break; } String str1 = str.toUpperCase(); System.out.println(str1); } }catch(IOException e){ e.printStackTrace(); }finally { try { if(br!=null){ br.close(); } }catch (Exception e){ e.printStackTrace(); } } } }
請輸入字串:
dsfsf
DSFSF
exit