import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.regex.PatternSyntaxException; public class SplitString { private static BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); /** * @param args */ public static void main(String[] args) { if (br == null) return; String str; // 文字列の読み出し try { str = br.readLine(); } catch (IOException e) { System.err.println("Read Fail: " + e); return; } if (str == null) return; // 適当なパターンで分割 String[] words; try { // words = str.split("\\s+"); // 空白の場合 // words = str.split("/"); // /の場合 UNIX風 words = str.split("\\\\"); // \の場合 Win風 } catch (PatternSyntaxException pe) { System.err.println("Invalid Pattern: " + pe); return; } catch (NullPointerException npe) { System.err.println("NullPo: " + npe); return; } if(words==null) return; for (int i = 0; i < words.length; i++) { System.out.println("(" + words[i] + ")"); } } }