Help!! i dont know how to make use of token from string tokenizer :(

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

You can modify this to serve your goal.
BufferedReader is=null;
try {
is = new BufferedReader(new InputStreamReader(new FileInputStream("Data.txt")));
StreamTokenizer st = new StreamTokenizer(is);
int n=0,k=0,q=0;
String[] s=new String[20];
String[] s0=new String[10];
while(st.nextToken() != StreamTokenizer.TT_EOF) {
        switch(st.ttype) {
          case StreamTokenizer.TT_EOL:
            s[k] = new String("EOL");k++;
            break;
          case StreamTokenizer.TT_NUMBER:
            s0[q] = Double.toString(st.nval);q++;
            break;
          case StreamTokenizer.TT_WORD:
            s[k] = st.sval; // Already a String
             k++;
            break;
          default: // single character in ttype
            s[k] = String.valueOf((char)st.ttype); k++;
        }  //end of while
   //   Some output processing here
}catch(IOException ioe){
   ioe.printStackTrace();
}catch(ArrayIndexOutOfBoundsException bx){
   System.err.println(bx);
}finally{
       try{      if(is !=null)     is.close();}catch(IOException ioe){;}
}

Similar Messages

  • I just got logic and need help i dont know how to make a track at all

    i just got logic and need help i dont know how to make a track at all

    Pancenter wrote:
    There was a time not too long ago when people respected the incredible amount of talent that contributed to this software...Everyone -wanted- to learn about the craft and "art" that goes into being a good engineer, musician, producer...etc.      
    Beginner's did enough reading and experimentation to at the very least, ask an intelligent question.
    pancenter-
    Hey Pancenter there are still lots of us about.
    I wouldn't take the original post too seriously - I may of course be naive but it sounds like it could be a troll to me!
    I learn a lot from reading the posts of the likes of you, Erik, Bee Jay, sampleconstruct, noeqplease etc so I hope you guys don't become too dispondent when you see posts like these.
    By the same token, I hope the Logic team continue to use their talents to develop powerful software that caters for the professional user, while allowing Garageband to continue to do its (excellent) job of providing for its market.

  • I was able copy the hardrive of my old macbook from "My Passport" onto the desktop on an older iMac. but i dont know how to make my hardrive and user name be the main one since someone had used it in the past and had their info on the comp. please help!

    I recently broke my 2008 macbook. i was able to use an external hardrive to back up my data onto My Passport. I was going to buy a new computer but a friend told me sher had an older version of the iMac. (not sure how old but it doesnt have a camera if that helps) i was able to hook it up and turn it on but i ran into a few problems. 1) the "authentic" user or whatever it says is someone who previously used the computer. i added me as a user but im not sure how to make me the main user. 2) after hooking up My Passport, i was able to drag my files and copy them to the desktop.(i think i did it correctly) now, i dont know how to make my hard drive and applications and iformation the "main " info. The current apps on the iMac are super old versions of iTunes and iPhoto and such. 3) while trying to open the apps from my macbook on the iMac, it said it didnt have the right software to open these apps.
    I am so computer illiterate so someone please help!!! Also, i do not have internet in my new apartment yet so if there is a way to make this happen without using the internet that would be preferred. sorry for the horrible spelling and poorly written paragraph.
    THANK YOU!!

    You are not going to be able to run your old system from the backup on this old computer as the hardware is incompatible.
    You need to get a new computer or a refurbished one.

  • Im having trouble changing my security questions, they are from years ago so i do not remember them and the reset email is no longer active,and i dont know how i can use the account because i added money to it but it asks for the questions. anybody help??

    im having trouble changing my security questions, they are from years ago so i do not remember them and the reset email is no longer active.., and i dont know how i can use the account because i added money to it but it asks for the questions. anybody help??
    this says it all..

    Welcome to the Apple Community.
    Contact Apple through iTunes Store Support, and explain that you have forgotten your 3 security questions, that you can reset your password, but doing so doesn't reset your security questions.
    Remember, support will receive hundreds, if not thousands of requests per day, some from people trying it on, others with little explanation and others that are written extremely poorly. Take the time to explain your situation properly, be precise and concise, brief but comprehensive.

  • I dont know how to make a partition help!

    I dont know how to make a partition help!

    Open Boot Camp Assistant, print the directions, read them carefully.
    Backup your Mac before you do anything.

  • My iphone 5's lock button is broken, and i believe its on "curtain mode" siri works ect... but i dont know how to make the screen turn on again

    My iphone 5 randomly froze so i used my accesibility button to lock the scre because my lock screen button is broken. After i locked it it wouldn't turn back on. The screen is off but i can still hear notifications and Siri. I dont know how to make it work. help?

    See: https://ssl.apple.com/support/iphone5-sleepwakebutton/

  • Just bought a new laptop but dont know how to transfer my itunes libary from one to the other i have signed into my account but still no music help please

    just bought a new laptop but dont know how to transfer my itunes libary from one to the other i have signed in my my new laptop but still no music help please !!!!!!

    Signing into the iTunes account has never made content magically appear... it still amazes me that people think this will actually work.
    Type "move itunes library" into the search bar or your favorite search engine.  You'll find multiple results for how to move the iTunes library.

  • TS4223 Someone help, i dont know how to put films on my ipod touch from my itunes on my computer?

    I bought 3 films yesterday off itunes on my computer, but now i dont know how to get them on my ipod?
    can someone help urgently please?

    It's similar to how you sync music to it. Connect the iPod to your computer and select it on the left-hand sidebar of your computer's iTunes (if you have iTunes 11 on your computer then you can enable the left-hand sidebar via option-command-S on a Mac, control-S on a PC), and then use the Movies tab on the right-hand side of iTunes to select and sync them to the iPod's Videos app

  • I have greyed out songs on my ipod and i dont know how to make them come back on my ipod and it wont work from my itunes library to my ipod

    I need to know how to make greyed out some songs turn bold. I have tried from my itunes library to my ipod but it still wont work. Can anyone help?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsync all music and resync
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                             
    - Restore to factory settings/new iOS device.

  • I have just created apple id i dont have any credit card so i dont know how to start using my id on my phone its telling me that my id isn't registered with apple store please help me asap thank u  d

    ok so please tell me how to start using my apple id
    or i cant cuz i dont have any banck account?

    The only way to create an Apple ID & not have a payment method associated with the ID, is to follow the directions here:
    http://support.apple.com/kb/HT2534
    With an existing ID, you either need a credit card or you need to redeem an iTunes gift card. So, in your case, either create a new ID, or associate a credit card with your existing ID, or redeem an iTunes gift card.

  • I just downloaded an app to my curve and dont know how exactly to use it ... help ?!

    i downloaded eOffice and also filescout to my phone so i could download some documents to my phone but im not exactly a phone person and lets say smart enough to figure this out myself.. someone help please..
    how do i open documents from my pc on my phone ? how do i download them .. or get them on to my phone ?

    They are ios apps, sorry for not specifying. I just went to my iPad, then iTunes and they show up there. Under the apps it says "install' But when I do that it says the app requires ios 6.0 or later and only have 5.1.1. When I read the requrements on the app on the iTunes store on the computer it said it only required 3.1. Anyway, can I put ios 6.0 on an iPad 2 and more important will ios 6 slow down or not run smoothly on the iPad 2? Thanks.

  • SECAM help, need to know how to make a secam project

    I Need to make a DVD that can be played in France.  I understand that the standard in France is SECAM.  I can't find a preset when making a project for SECAM or info on the web about what resolution to make if I were to create a custom preset.
    Any help would be great. Thanks

    Jim Simon wrote:
    As a general rule, you edit in a project that matches your media properties.  If your final delivery needs to be different, you do that during or after export.
    This is true.  I have shot in NTSC and had to send a PAL version of the final video over to Europe, so I edited in NTSC and converted it to PAL in Encore.  Worked fine, from what the client told me, although I never got to see the final PAL version since we don't have a PAL compatible DVD player in the office.  So I couldn't tell you if there were any problems I may have noticed that the client might have shrugged off (like field-dominance problems).

  • HELP!  Dont know how to bring up my preferences...

    Whenever I am on iChat and I go to my preferences under iChat the big window of preferences doesn't come up like it used to. Now a little window called accounts comes up... where it has my aim screenname listed and a button that says Server Options but it is grey and I cant click on it...
    What do I do!?!

    Hi LaurenL,
    Seeing only one of the Preference icons is not that uncommon.
    Go to Uers/(your Mac account name)/Library/Preferences and delete com.apple.ichat.plist
    Restart ichat and you will have all icons back.
    Many other apps have a small white button on the right of the top of the toolbar which will hide/reveal the toolbar in full but iChat does not have this on the preferences Toolbar.
    12:26 AM Thursday; August 10, 2006

  • Help! Dont know how garage band works

    Im trying to create a ringtone for my iphone but im not working out how to actually cut the song.
    Im kinda slowy going off my head so please put me out my misery

    What happened was somehow i heard of a pat metheny (i forget how to spell his name) the jazz guitarist's seminar about how he loves making music on his mac w/ garageband so i signed up to read & watch that seminar. So after a few months i was alerted to a whole host of vid's, (seminars ) many topics from apple by email. When i signed up the final step was a sign in page , is that what your getting , man i thought everyone was getting a chance to see it . There are 3 video's you can watch one is 33 minutes long , another 22 minutes & a 16 minute. What if you try going to apple .com /seminars , i 'm going to investigate, maybe it's taking you to my sign in page, have you tried signing in on the generic sign in page

  • I have previously syncd my account,but my laptop got corrupted,so due to that all my data got delete,i do have my account id and password but i dont know how to sync using my id nd password

    '''bold text'''

    If you are setting up sync on a device that has a fresh installation of Firefox, it is considered a "new device".
    See this: <br />
    https://support.mozilla.com/en-US/kb/add-a-device-to-firefox-sync

Maybe you are looking for