How can i read a string with nextToken() of StreamTokenizer

I need for my class paper to read a string from a file and i used the StreamTokenizer's method nextToken but i can not read a string with it. my code is:
StreamTokenizer st = new StreamTokenizer(the code that gets the input from the file)
String line;
while ((line !=br.readLine()) != null) {
String surname = (st.nextToken()).trim();
but it gets me some error of:
int can not be dereferenced
what should I do to get the string i need?

Look at the API for java.io.StreamTokenizer. In particular, look at the return type for nextToken().
Good luck.

Similar Messages

  • How can I read a file with ASCII Special Character into a SQL table using SSIS 2008?

    I've tried everything to read this file and am getting no where.   Help how can I read this file and load a SQL table?
    RS - AscII - 30  (Record Separator)
    GS - AscII - 29 (Group Separator)
    Thank you for your assistance - Covi
    Mark Covian

    We can use script component as source/transformation to read the text file and assign the contains to a string. Split the string by chr(30)  i.e RS and finally stored into an array or write to the output buffer of the script component.
    For example on how to use script component refer this link
    http://social.technet.microsoft.com/Forums/en-US/6ff2007d-d246-4107-b77c-624781baab38/how-to-use-substring-in-derived-column-in-ssis?forum=sqlintegrationservices
    Regards, RSingh

  • How can I substitute a string with another string in a file

    I have a file. I have a substitute a keyword with another string in all the occurences of a file. How can I do this?

    I'm gonna give you the benifit of the doubt and assume you didn't mean to double post your question.
    As to substitute a keyword with a string one way is to read in the file and run it through a StreamTokenizer class to break it into words. Pull one word at a time, check it, and stick it into a StringBuffer. Once your done with the file overwrite it with what is in the StringBuffer.
    Another way might be to use the RandomAccessFile class, but I'm not really familiar with that because I hardly ever use it.

  • How can I read two channels with fieldpoint and labview

    I'm trying to read two or more channels with the TC 120, and I follow the examples of sopport page, but doesn't work.
    What can I do?

    For more information about reading or writing to or from multiple channels in Fieldpoint, please refer to:
    How Do I Read or Write to Multiple Channels on a Fieldpoint Module in LabVIEW?
    This should enable you to read multiple channels. The only other option available is to use one fp open.vi, multiple Create Tag.vi's and multiple FP Tag Read.vi's.

  • How can i read XML string in a loop???

    i changed xml file reader to xml string reader by
    looking around this and other forums.
    here is the code.
    public class XMLTester2 {
        public static void main(String[] args) {
            String s = "<firsttag><secondtag>123</secondtag></firsttag>";
            java.io.Reader reader = new java.io.StringReader(s);
            org.xml.sax.InputSource source = new org.xml.sax.InputSource(reader);
            org.w3c.dom.Document doc = null;
            javax.xml.parsers.DocumentBuilderFactory fact = javax.xml.parsers.DocumentBuilderFactory.newInstance();
            try {
                javax.xml.parsers.DocumentBuilder builder = fact.newDocumentBuilder();
                doc = builder.parse(source);
            } catch (javax.xml.parsers.ParserConfigurationException pce) {
            } catch (org.xml.sax.SAXException se) {
            } catch (java.io.IOException ioe) {
            } finally {
                try {
                    reader.close();
                } catch (java.io.IOException ignored) {
    }i put this stuff into a loop, but i always ends up
    having new in the loop.
                String inputLine = "Start";
                // define what's needed for XML messages
                Reader reader = new StringReader(inputLine);
                InputSource source = new InputSource(reader);
                Document doc = null;
                DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = null;
                Node xmlNode = null;
                try {
                    builder = fact.newDocumentBuilder();
                } catch (ParserConfigurationException pce) {
                // -->
                while ( (inputLine = in.readLine()) != null) {
                    System.out.println("readLine() : {" + inputLine + "}");
                    reader = new StringReader(inputLine);
                    source.setCharacterStream(reader);
                    try {
                        doc = builder.parse(source);
                    } catch (SAXException se) {
                        System.out.println("SAXException : " + se);
                        System.out.println("SAXException source : " + source.toString() );
                        se.printStackTrace();
                    } catch (IOException ioe) {
                        System.out.println("IOException : " + ioe);
                    } finally {
                        try {
                            reader.close();
                        } catch (IOException ignored) {
                    reader = null;i know putting new in the loop is VERY bad.
    i gotto get ride of this new from the loop.
    can anyone help me?

    i know putting new in the loop is VERY bad.
    i gotto get ride of this new from the loop.Don't design your application based on one-liners you heard somewhere. Do some timings to see if it matters. My guess would be that parsing an XML file would take a fair bit longer than creating a StringReader object. And you do need a new StringReader each time, they aren't reusable, so the alternatives are not obvious. And don't accept my guess about the timings, check it for yourself.

  • How can one read ClarisWorks files with MS Word / Excel ?

    Somebody handed me this .cwk file, and wants to be using it in their Office program.
    Thanks for your time!

    Hi, Bruce. If you don't have access to any version of ClarisWorks or AppleWorks yourself, and the person who originated the .cwk file is unavailable to resave it in a more suitable format, MacLink Plus Deluxe can translate it into any of several Word formats.
    If you're in a position where you frequently receive files in a variety of formats that must be used by others who aren't conversant with all those formats, MLPDeluxe would be a very good investment for you.

  • How can I parser a String with javax.xml.parsers.DocumentBuilder?

    Normally the DocumentBuilder can parse files, InputSource,InputStream or uri. but what if I want to parse an editing String the user created in an EditPane or JTextComponent?

    new InputSource(new StringReader(theString))

  • How can i read my ebooks with authorizing trouble?

    i bought a sony reader PRS-300 over chrismas and everything was working fine until my laptop broke and i had to use to my sisters.
    i have authorized her laptop as well. but now i cant read any of my ebooks. even when i buy new ebooks it doesnt work.
    i have uninstalled and reauthorised it many times and now it is sayin ive authorized it too many times and cant do it again. but even if i did i doubt my ebooks would work on it.
    can anyone help me please? im going on holiday soon to see my dad who got me it and if im not using it he wont be happy.
    on start up and when i try to add a new book, i get this message.
    Error getting license
    License server communication problem: E_LIC_ALREADY_FULFILLED_BY_ANOTHER_USER
    i get this when i try authorising again.
    E_ACT_TOO_MANY_ACTIVATIONS http://adeactivate.adobe.com/adept/Activate 908:2908:6908 urn:uuid:827fb462-5fd6-4bfa-89a2-b065a05bc928

    You cannot.

  • How can I read and work with the e-mail on one IMAC (running 10.7.3) from my MacPro Power PC5 (running 10.5.8)

    I would like to be able to work the e-mails on my IMAC (Lion 10.7.3) from my Mac Pro Power PC5 (running Leopard 10.5.8).  I want to be able to see all the folders and have actions show up on the other computer.  In other words, if I delete the e-mail I want it to disappear in real time from the other computer.  The same would be for moving messages in and out of different folders.  Can this be done without setting a server?  If not, then what server version could I install on the MacPro that would let me do this?

    That is the way IMAP should work.
    Like gMail or iCloud, both of which can be setup on both Macs...
    Do not delete the old account yet. sign up for an iCloud account if you haven't.
    I understand .mac mail will still come through. Do not delete the old account yet.
    You cannot use .mac or MobileMe as type of Account, you have to choose IMAP when setting up, otherwise Mail is hard coded to change imap.mail.me.com to mail.me.com & smtp.mail.me.com to smtp.me.com, no matter what you try to enter.
    iCloud Mail setup, do not choose .mac or MobileMe as type, but choose IMAP...
    On second step where it asks "Description", it has to be a unique name, but you can still use your email address.
    IMAP (Incoming Mail Server) information:
    • Server name: imap.mail.me.com
    • SSL Required: Yes
    • Port: 993
    • Username: [email protected] (use your @me.com address from your iCloud account)
    • Password: Your iCloud password
    SMTP (outgoing mail server) information:
    • Server name: smtp.mail.me.com
    • SSL Required: Yes
    • Port: 587
    • SMTP Authentication Required: Yes
    • Username: [email protected] (use your @me.com address from your iCloud account)
    • Password: Your iCloud password

  • HT1391 How can I read and print digital booklets that are downloaded togheter with the recordings I purchased

    How can I read and print digital booklets that are downloaded togheter with the albuns I bought?

    cu is right.
    classloader returns the URL of your resource. You can the jar using something like the following...
    ClassLoader classloader = this.getClassLoader();
    url = classloader.getResource("your_resouces...");
    if(url == null)
    System.out.println("cannot find resource ");
    return null;
    String jar = url.getFile();
    jar = jar.substring(jar.indexOf("/")+1, jar.lastIndexOf("!")).replace('/', '\\');
    obviously, this code snippet works on windows only. Now you have the jar file path. I use Jar file classes to access the jar file. (e.g. you can search for each class files)
    Ming

  • How can I read pdf files from LabVIEW with different versions of Acrobat reader?

    How can I read pdf files from LabVIEW with different versions of Acrobat reader?
    I have made a LabVIEW program where I have possibility to read a PDF document.  When I made this LabVIEW program it was Acrobat Reader 5.0.5 that was installed on the PC. Lather when the Acrobat Reader was upgraded to version 6.0, there was an error when VI tries to launch the LabVIEW program. And Later again when we upgraded to Acrobat Reader 7.0.5 I must again do some changes and rebuild the EXE files again
    It isn't so very big job to do the changes in one single LabVIEW program, but we have built a lot of LabVIEW programs so this take time to due changes every time vi update Acrobat Reader. (We have build EXE files.)
    The job is to right click the ActiveX container and Click "Insert ActiveX Object", then I can brows the computer for the new version of acrobat Reader. After this I must rebuild all the "methods" in the Activex call to make the VI executable again.
    Is there a way to build LabVIEW program so I don't have to do this job every time we update Acrobat Reader?
    This LabVIEW program is written in LabVIEW 6.1, but I se the problem is the same in LabVIEW 8.2.
    Jan Inge Gustavsen
    Attachments:
    Show PDF-file - Adobe Reader 7-0-5 - LV61.vi ‏43 KB
    Read PDF file.jpg ‏201 KB
    Show PDF-file - Adobe Reader 5-0-5 - LV61.vi ‏42 KB

    hi there
    try the vi
    ..vi.lib\platform\browser.llb\Open Acrobat Document.vi
    it uses DDE or the command line to run an external application (e.g. Adobe Acrobat)
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • How can I read pdf with ebook reader on JounE touch

    How can I read pdf with ebook reader and where could I put the pdf in Journe

    Hi there
    You said that you want to read pdf with ebook reader .
    For me ,i usually read the pdf files using another pdf reader which supports to read the pdf files directly.
    And i am now just using their free trial.
    You can also have a try.
    +Message was edited: Advert has been removed+

  • I have a problem with the mac can not read video files with the extension IMOD. How can I solve this problem?

    I have a problem with the mac can not read video files with the extension IMOD. How can I solve this problem?

    By doing a Google search. 

  • How can I search the tree with a given string?

    How can I search the tree with a given string?
    I don't find any function like "search(...)".
    I want to find the tree nodes which include the given string.
    Thanks.

    Try it with .com instead of .ca - fixes it for me (corporate firewall blocks .ca here)
    http://spendolini.blogspot.com/2013/09/working-with-apex-tree.html
    Anyway - it links to an article of mine which describes interacting with the tree: Tom's Blog: Working with the tree in Apex. There is also a demo application on apex.oracle.com: http://apex.oracle.com/pls/apex/f?p=54687:38

  • I downloaded the ipad app for kindle, my wife has the app on her iphone also with several books that she has downloaded to her iphone, how can i read these books on my ipad?

    I downloaded the ipad app for kindle, my wife has the app on her iphone also with several books that she has downloaded to her iphone, how can i read these books on my ipad?

    By sharing the same Amazon account on each device. You may also have to use the same Apple ID and password.

Maybe you are looking for

  • Restrict user could not get output of conc request more than one

    Hi all, I actually have one scenario that I want to delete or purge concurrent requests after getting view output. Please tell me how it is possible to purge request , Its simple means to prohibit the user to see out 2nd time. "I have one option that

  • Table for BETRG Field

    Hi Experts, I am working on an ESS MSS project. Currently I am working on a report in which I have to find the expenses of an employee. The field BETRG gives me the expenses for that employee. but I am unable to find a table for this field. Does anyb

  • SAP XI fourm search not working

    Hi I have a strange problem...I was trying to search on SAP XI forums from yesterday but the search results are empty for every search string we give....Is this happening only to me or some others are also facing the same problem... Thanks

  • What is the cisco ironport C680 and M680 configuration backup file size?

    what is the cisco ironport C680 and M680 configuration backup file size?

  • Continuous layout on JFrame resize?

    hi, on my machine (win2k) when you resize a JFrame with the mouse, the contents are not resized until you have released the drag. Is this a property of my java/OS settings or a limitation of Swing? JSplitPane has a setContinuousLayout method which so