Azrul Azhar
Posts: 9
Nickname: bllizard
Registered: Jun, 2002
|
|
String Tokenizer Output
|
Posted: Nov 10, 2002 11:51 PM
|
|
Advertisement
|
Hi,
I would like to ask how to manipulate the token that are taken from string tokenizer. For example :
input = a b 1 f 986
supposed output: a b 1 f 986
How to make the output look like this? Output = (a,b,f),(1,986)
Below is the source code of Algebra.java ___________________________________________________________ import java.io.*; import java.util.*;
/** * Read and print, using BufferedReader from System.in, onto System.out */ public class Algebra {
public static void main(String[] av) {
try { BufferedReader is = new BufferedReader(new InputStreamReader(System.in)); String inputLine; System.out.print("Input ="); while ((inputLine = is.readLine()) != null) { System.out.println("Output="+inputLine); StringTokenizer st = new StringTokenizer(inputLine, ", |");
while (st.hasMoreElements()) System.out.println("Token: " + st.nextElement()); break; } is.close(); } catch (IOException e) { System.out.println("IOException: " + e);
} } } ------------------------------------------------------------
Thank You
|
|