Read a Txt file that it is in a PC in a LAN

Hello:
Can you tell me how to read a txt file that it's in a LAN
trouh IP with
Lingo?
Do I need any Xtras or can I do it only with Lingo?
Have you some examples?
Many thanks in advance.

Hi,
look at the help file about "getNetText" and
"downloadNetThing"
hth

Similar Messages

  • How to read from txt file that has words in between?

    Hi all,
    I am using Labview 8.2.
    I would like to read from a text file.  I have data (after each time it is has averaged over 100 waveforms) repeatedly stored on to the file.  The idea is to further improve SNR in post processing by again averaging the data (that has been averaged over the 100 waveforms).  
    I can get LabView  to save the data repeatedly into the file, so it keeps getting appended.
    The problem is to read the data in labview so I can now again average it.  The problem is the labview seperates the sets of data with the following:
    " Channels    1    
    Samples    9925    
    Date    2008/10/28    
    Time    17:16:11.638363    
    X_Dimension    Time    
    X0    -3.0125000000000013E-3    
    Delta_X    2.500000E-6    
    ***End_of_Header***        "
    So When I read it, it only sees the first set of data.
    Can someone please tell me how to read all the sets of data in labview?
    I have attached the file I want to read "acquiredwaveform.txt"  and the basic VI (really basic btw) to read the file.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    ReadFileAndAverage.vi ‏48 KB
    acquiredWaveform.txt ‏605 KB

    Thanks again DFGray for the comments. 
    After the correlations to find the peak positions, i just take the max value.  And you are right the accuracy is limited by the number of  samples per cycle.  Perhaps it would be clearer if you see the code.
    1) Basically I get a signal on the up and downslope of the sine wave.  On the down slope however the signal is negative, i.e. its is flipped.  So before I shift and average...I 'cut' the waveform into 4 (when cycles per buffer = 2, then I get 4 signals, 2 on the up slope and 2 on down slope) bits.  Counting from one, I flip the even number, cut it, and but an array of waveforms which is then sent to be convolved and shifted.
    2) Array of waveforms are stored to be phased shifted (Convolve and shift vi) and averaged (entire averaging vi which uses the convolve and shift vi as a sub vi). 
    * Phase shifting doesn't work when I cut and put it together (So something is wrong in cut waveform vi) 
    * Also if it isn't too time consuming could you give me an example of interpolating and shifting thing.
    * Also if you have any comments regarding the following VIs please let me know.  
    Thanks 
    Attached is:
    1) Cut waveform vi
    2) Convolve and shift
    3) Entire averaging 
    Attachments:
    SubVICutWaveforms.vi ‏37 KB
    SubVIConvolveShift.vi ‏30 KB
    SubVIEntireAveraging2.vi ‏43 KB

  • Help reading a .txt file from the hard drive....

    Hi guys,
    Ok... I need to know how to read a .txt file from the hard drive... I have an example on how to read from a disk, but I don't have a disk drive. I could be confusing terminology, but I don't think I am. Here is the code I have for reading from a disk.. please let me know how I should change it to read from a hard drive.
    Also, when the error pops up, it says that it can't read another .txt file that is not specified in the code... any ideas how that is occuring? Please advise.
    import java.io.*;
    public class TEST {
    public static void main(String args[]) throws Exception{
    FileReader fr = new FileReader("customer.txt");
    BufferedReader bfr = new BufferedReader (fr);
    String s;
    while ((s=bfr.readLine())!= null){
    System.out.println (s);
    fr.close();
    }

    Ok... I need to know how to read a .txt file from the
    hard drive... I have an example on how to read from a
    disk, but I don't have a disk drive. I could be
    confusing terminology, but I don't think I am. Here
    is the code I have for reading from a disk.. please
    let me know how I should change it to read from a
    hard drive.The code will be the same, regardless of where the file is located. It's just the filename that will be different.
    Also, when the error pops up, it says that it can't
    read another .txt file that is not specified in the
    code... any ideas how that is occuring? Please
    advise.Probably becuase the class file (compiled version of the source code) is a different version to the source code, i.e. the source code hasn't been recompiled since the source code was changed.
    How does this relate to EJBs?

  • Assistance in Reading a .txt file

    I'm newbie on Java and I have a problem
    I'm doing a homework on Systems and I need to read a .txt file [It would be on the same folder as the Java file].
    The catch is that I have to read by Lines, Each Line could have as much as 3 words[tokens] as little as one.
    I also have to read the characters on the words/tokens to identify if they are valid.
    I have thought of 2 ways of doing this.
    Reading ALL the line and dividing the words by the Spaces.
    Or read the words by tokens and then having a flag to know when the line jumps.
    Example of the text file:
    ORG %011010
    Et1 equ $ffFF
    ;Comentary # 1
    dos LDAA @456
    END
    I hope I'm being clear.
    Now, I'm not looking to have my homework done for me, but I am looking for some pointers.
    I've tried the Scanner class but I just don't know the right methods I guess... I've also heard the Token StringTokenizer class works. But I have no clue.
    Someone could give me pointers? which Class would be the right one and which methods?
    I've been Struggling with this all week.
    Help will be really appreciated.

    I would use the Scanner class to read an entire line. If you don't know what methods to use then read the Java API and the explanation for each method of the Scanner class. Write some code to experiment and see what those methods do. Then when you have an entire line I would use String.split as StringTokenizer is/has been deprecated.

  • How can i read only .txt file and skip other files in Mail Sender Adapter ?

    Hi Friends ,
                       <b> I am working on scenario like , I have to read an mail attachement and send the data to R3.</b>
                        It is working fine if only the .txt file comes.
                      <b>Some times ,html files also coming along with that .txt files. That time my Mail adapter fails to read the .txt file.</b>
                       I am using PayLoadSwap Bean and MessageTransformBean to swap and send the attachment as payload .
                         <b>Michal as told to write the Adapter module to skip the files .But i am not ware of the adapter moduel . If any blogs is there for this kind of scenarios please give me the link.</b>
                           Otherwise , please tell me how to write adapter module for Mail  Sender Adapter?
                      How to download the following
                        newest patch of XI ADAPTER FRAMEWORK CORE 3.0
    from SAP Service Marketplace. Open the file with WinZip and extract the following
    SDAs:
    &#61589;&#61472;aii_af_lib.sda, aii_af_svc.sda
    &#61589;&#61472;aii_af_cpa_svc.sda
                        I have searche in servive market place .But i couldn't find that . Can you please provide me the link to download the above .
                      If any other suggestions other than this please let me know.
    Regards.,
    V.Rangarajan

    =P
    Dude, netiquette. Messages like "i need this now! Do it!" are really offensive and no one here is being payed to answer anyone's questions. We're here because we like to contribute to the community.
    Anyway, in your case, just perform some search on how you could filter the files that are attached to the message. The sample module is just an example, you'll have to implement your own. Tips would be to query the filename of the attachments (or maybe content type) and for the ones which are not text, remove them.
    Regards,
    Henrique.

  • Interesting ? @ servlet reading a txt file

    hi friends,
    i need ur help for one interesting problem i m facing.
    I want to read a txt file and wanna display the text from that file into an html, using a servlet.A txt file contains sentences( words with spaces in between ).When servlet reads the file, it is reading the whole sentence ,but while displaying that sentence, it is just showing the first word of the sentence.
    html is not able to read the space between the words.
    so what do i suppose to do now.
    waiting for ur replies.......
    thanx
    amit

    hi friends ,
    i m giving the code , just give it a try//
    This is a servlet ---------------------------------------
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class AdminGraphServlet extends HttpServlet
    Properties ht;
    FileInputStream fin;
    FileOutputStream fout;
    String s15,st;
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException
    ht = new Properties();
    try
    fin = new FileInputStream("Data.txt");
    catch(FileNotFoundException e)
    System.out.println("FileNotFound");
    try
    if(fin != null)
    ht.load(fin);
    s15 = (String)ht.get("title");
    fin.close();
    catch(IOException e)
    System.out.println("Error Reading File");
    PrintWriter out = res.getWriter();
    res.setContentType("text/html");
    out.println("<html><body>");
    out.println("<form method=post action=http://localhost:8080/servlet/MyServlet>");
    out.println("<table><tr>");
    out.println("<tr><td>Title</td>");
    out.println("<td><Input Type=Text name=title value="+ s15 +"> </td></tr>");
    out.println("</table>");
    out.println("<input type=submit name=submit value=submit>");
    out.println("<input type=hidden name=check value=save>");
    out.println("</form>");
    out.println("</body></html>");
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
    String Scheck = req.getParameter("check");
    PrintWriter out1 = res.getWriter();
    String ttl = req.getParameter("title");
    if(Scheck.equals("save"))
    ht.put("title",ttl);
    fout = new FileOutputStream("Data.txt");
    ht.store(fout,"Data");
    fout.close();
    out1.println("<html><body>");
    out1.println("<h1>Stored This Data Successfully</h1>");
    out1.println("</html></body>");
    txt file is having a line
    title=Are you smart enough?
    The servlet should display this sentence in a text box.
    But it is displaying only "Are".
    still waiting...
    have nice time..
    amit

  • Help! How to read a .txt file into a Java class and make 2D array?

    Hi guys,
    Im a newbie with arrays, just started really using them.. please bear with me if I don't seem to understand much..
    I have a .txt file that contains either a square or rectangle (random width and length).. How can I read each line into a Java class into a 2D array with rows and columns?

    Example :
    import javax.swing.*;
    import java.util.ArrayList;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.File;
    public class ReadInto2DArrayExample {
        public static void main(String[] args) {
            ArrayList array = new ArrayList();
            char [][] twoDimesionArray = null;
            try
                JFileChooser fileChooser = new JFileChooser();
                if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                    File file = fileChooser.getSelectedFile();
                    BufferedReader reader = new BufferedReader(new FileReader(file));
                    String data;
                    //Read from file
                    while ((data = reader.readLine()) != null)
                        //Convert data to char array and add into array
                        array.add(data.toCharArray());
                    reader.close();
                    //Creating a 2D char array base on the array size
                    twoDimesionArray = new char [array.size()][];
                    //Convert array from ArrayList to 2D array
                    for (int i = 0; i < array.size(); i++)
                        twoDimesionArray[i] = (char [])array.get(i);
                    //Test the 2D Array
                    for (int y = 0; y < twoDimesionArray.length; y++)
                        char [] temp = twoDimesionArray[y];
                        for (int x = 0; x < temp.length; x ++ )
                            System.out.print(temp[x]);
                        System.out.println("");
            catch (Exception ex)
                ex.printStackTrace();
    }

  • Read a .txt file

    I'm trying to find out how to read a .txt file and simply assign its contents to a variable. Is this possible?
    [Edit] Right after posting I found this page which seems like it might be in the direction I want to go but I haven't checked it out completely yet: http://extendscript.blogspot.com/2009/06/read-tab-delimited-text-file.html
    Just posting the link for future searchers or if anyone will tell me 'Hey! That's not what you're looking for!'

    For anyone interested, the simplified answer for me was:
    var fileToParse = File ('path');
    fileToParse.open('r');
    var dataToGet = fileToParse.readln();
    fileToParse.close();
    I only needed the one line, so thats why my example above is so simple.

  • How XI will read the .txt file

    Experts,
    i AM WORKING ON A FILE BAPI synchrounous scenario.
    Sender will drop the required file on XI directory and XI will pull the file and map it with the BAPI u2013 and crate services  entries in SAP SCM. If errors are encountered during the process they are returned to the client in a report or as erroneous file.
       *I have a .txt file( tab delimitted file)  in the folowing structure
    H                       NAME                        date            ***                 data_txt                         676869*
      C             a                           b             c
      C             d                           e             f
    H                      name                           Account            brat                     abcc                             12333
      C             a                             b               c
      C             d                             e               f                          hjhdkf
    like this  multiple entries, ll be getting .
    Based on H ( indicator), Have to get the data. How will I do in XI file  adapter?  Please help me how should I design the file adapter so that It can read the .txt file.
    I have created the sender data type similarly to the structure of BAPI.
    Note; H indicates teh Header and D indicates teh sublines. Together it is called one service entry. Aagain Next 'H' indicates the strat of next service entry.
    Thanks
    Veeru

    Nutan,
      I want the flat file  data in teh following xml format
    <Records>
        <Header>
             <Item>
                    <data1>1</data1>
                    <data2>2</data2>
              </item>
       </header>
    <Header1>
             <Item>
                    <data1>1</data1>
                    <data2>2</data2>
              </item>
       </header1>
    </Records>
    Records-- o to unbounded
    Header--- 0 to 1
    header1-- 0 to 1
    Item--- 0 to unbounded
    My input .txt file ,  fields are separated by a tab. I mean its a tab delimitted file.
    The main tag Records is 0 to unbounded.
    How to do the content conversion for the  same.
    Thanks
    Veeru
    Edited by: viru srivastava on Dec 20, 2009 2:56 AM

  • Calling a variable from a external txt file that is equal button name

    Hello
    I have a variable in an external txt file that is = the name
    of my button. I have loaded the file in to flash in an object
    called my_lv.
    How do I make line three in the code valid ?
    _root.map.name1900.onRollOver=function() {
    this._alpha=20;
    txName=my_lv.+(this._name); // this line is wrong!! I need
    to place name1990._name in side the ().

    do you have an object called "my_lv" and a child object have
    named as "name1900" . ie "my_lv.name1900"\
    if i am right then...
    >> txName=my_lv.+(this._name); //
    should be
    txName= eval("my_lv."+ this._name)

  • Continiously read a txt file

    Hello fellows,
    is there a way to read a *.txt file continiously without doing the simple while loop wich burns all the CPU ??
    This txt file is generated by another application that pick up messages from a pipe and register messages in the txt file.
    As a final goal the messages read in the txt file will control other executions in the vi.
    Attached files: vi in LabVIEW 8.0 and the txt file.
    Attachments:
    Zip.zip ‏6 KB

    Thanks for your interest ! !
    The process will be as follows:
    1-an application reads text in a serveur pipe and write it into the txt file.
    2-The LabVIEW vi reads in loop the txt file and sort out the txt value each time that's updated by the application running in parralel.
    The goal is to synchronize the labview execution with the new messages arriving in the txt file.
    Thanks for your suggestions on how can I continiously read the txt file and take an action in the vi each time the txt file is updated with new text.
    See you...

  • Need a VB-Script that read a txt-file and only the lines that are new since last time

    Hi,
    I need help to write a VB script that read all new lines since the last time.
    For example:  The script reads the textfile at specific time, then 10 minutes later the script read the file again, and it should now only read the lines that are new since last time. Anyone that has such a script in your scriptingbox?
    cheers!
    DocHo
    Doc

    Based on the excellent idea by Pegasus, where is a VBScript solution. I use a separate file to save the last line count read from the file, then each time the file is read I update the line count. Only lines after the last count are output by the program:
    Option Explicit
    Dim strFile, objFSO, objFile, strCountFile, objCountFile, strLine, lngCount, lngLine
    Const ForReading = 1
    Const ForWriting = 2
    Const OpenAsASCII = 0
    Const CreateIfNotExist = True
    ' Specify input file to be read.
    strFile = "c:\Scripts\Example.log"
    ' Specify file with most recent line count.
    strCountFile = "c:\Scripts\Count.txt"
    ' Open the input file for reading.
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(strFile, ForReading)
    ' Check if the line count file exists.
    If (objFSO.FileExists(strCountFile) = False) Then
        ' Initial count is 0, so all lines are read.
        lngCount = 0
    Else
        ' Open the line count file.
        Set objCountFile = objFSO.OpenTextFile(strCountFile, ForReading)
        ' Read the most recent line count.
        Do Until objCountFile.AtEndOfStream
            lngCount = CLng(objCountFile.ReadLine)
        Loop
    End If
    ' Read the input file.
    lngLine = 0
    Do Until objFile.AtEndOfStream
        ' Count lines.
        lngLine = lngLine + 1
        strLine = objFile.ReadLine
        If (lngLine >= lngCount) Then
            ' Output the line.
            Wscript.Echo strLine
        End If
    Loop
    ' Close all files.
    objFile.Close
    If (lngCount > 0) Then
        objCountFile.Close
    End If
    ' Ignore last line of the file if it is blank.
    If (strLine = "") Then
        lngLine = lngLine - 1
    End If
    ' Save the new line count.
    Set objCountFile = objFSO.OpenTextFile(strCountFile, _
        ForWriting, CreateIfNotExist, OpenAsASCII)
    objCountFile.WriteLine CStr(lngLine + 1)
    objCountFile.Close
    Richard Mueller - MVP Directory Services

  • Scenario to read from txt-file and create a sales order

    Hi,
    i have started creating a scenario to read from an txt-file and to create a sales order.
    When i activate my scenario, i get the following message :
        no scenario step (vBIU) associated for this step for the incoming system (SysId)
    When i look into the detailed xml-file i see that all the records are read from the file, but there is no next step to be treated.
    Has somebody any idea how this come ?
    -<Msg MessageLog="true" msglogexcl="false" logmsg="0009" recording="true" BeginTimeStamp="20111202095144" MessageId="11120209514499820828C0A801674F24" xmlns="urn:com.sap.b1i.vplatform:entity">-<Header><msglog b1ifactive="true" always="false" step="Default message log"/>-<Resumption><starter ipo="/vP.0010000138.in_FEAN/com.sap.b1i.vplatform.runtime/INB_FI_EXST_ASYN_NAM/INB_FI_EXST_ASYN_NAM.ipo/proc"/></Resumption><IPO tid="11120205535899820808C0A801678C54" Id="INB_FI_EXST_ASYN_NAM"/><Sender Id="0010000138"/><Inbound file="ORDERS_TEST" ext="csv" path="C:\TEMP\In" pltype="txt" wrap="" deli=";"/></Header>-<Body><Payload Type="File exist" Role="T"/>-<Payload Role="S">-<io xmlns="urn:com.sap.b1i.bizprocessor:bizatoms" pltype="txt">
    -<row>
    <col>OH</col>
    <col>0000087077</col>
    <col>201110041205</col>
    <col>220</col>
    <col>9</col>
    <col>201110191702</col>
    <col>8710624300012</col>
    <col>8714252008609</col>
    <col>8710624300012</col>
    <col>8714252008609</col>
    <col>8710624300012</col>
    <col>N</col>
    <col>N</col>
    <col>N</col>
    </row>
    -<row>
    <col>OL</col>
    <col>1</col>
    <col>8711715844378</col>
    <col>20</col>
    </row>-<row>
    <col>OL</col>
    <col>2</col>
    <col>8711715844392</col>
    <col>60</col>
    </rowrow>
    <col>OL</col>
    <col>16</col>
    <col>8710251791092</col>
    <col>280</col>
    </row>
    </io>
    </Payload>
    </Body>
    </Msg>
    This is my final atom :
    <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="" utils2:force=""><xsl:output method="xml" encoding="UTF-8" indent="yes"></xsl:output><xsl:param name="atom"></xsl:param><xsl:param name="sessionid"></xsl:param><xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]"></xsl:variable><xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"></xsl:variable><xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"></xsl:variable><xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover=&apos;P&apos;]/@Id"></xsl:variable><xsl:template match="/">
    <Msg xmlns="urn:com.sap.b1i.vplatform:entity">
    <xsl:copy-of select="/vpf:Msg/@*"></xsl:copy-of>
    <xsl:copy-of select="/vpf:Msg/vpf:Header"></xsl:copy-of>
    <Body>
    <xsl:copy-of select="/vpf:Msg/vpf:Body/*"></xsl:copy-of>
    <Payload Role="R" id="{$atom}">
    <xsl:call-template name="transform"></xsl:call-template>
    </Payload>
    </Body>
    </Msg>
    </xsl:template><xsl:template name="transform">
    <FinalAtomResult xmlns="">
    <BOM>
    <BO>
    <AdmInfo>
    <Object>17</Object>
    <Version>2</Version>
    </AdmInfo>
         <Documents>
         <row>
         <DocDate>
              <xsl:copy-of select="$msg/io/row[0]/col[2]/text()"></xsl:copy-of>
         </DocDate>
         <DocDueDate>
              <xsl:copy-of select="$msg/io/row[0]/col[5]/text()"></xsl:copy-of>
         </DocDueDate>
         <CardCode>KD10251</CardCode>
         <NumAtCard>
              <xsl:copy-of select="$msg/io/row[0]/col[1]/text()"></xsl:copy-of>
         </NumAtCard>
         <U_PMX_JD_COMP>32</U_PMX_JD_COMP>
         </row>
                          </Documents>
         <Document_Lines>
         <xsl:for-each select="$msg/io/row">
         <row>
         <BarCode>
              <xsl:copy-of select="$msg/io/row[*]/col[2]/text()"></xsl:copy-of>
         </BarCode>
         <Quantity>
              <xsl:copy-of select="$msg/io/row[*]/col[3]/text()"></xsl:copy-of>
         </Quantity>
         </row>
         </xsl:for-each>
         </Document_Lines>

    Mike,
    you were right, you may not specify the extension of a file.
    Another thing i detected is that the loop of my data start with the index 1 instead of 0 !!!
    In this scenario, i have to read all the lines of the file and each time i should do a SQL-query,
    so that i can use the result to build my sales document.
    Do you know if it this is possible or have you any idea how to do this ?
    thx,
    Mario

  • Reading a Txt file from SDCard...advise sought.

    Hey,
    Just a quick post to see if any of you kind people would be able to help me out here. I'm intending to have a database (simply perhaps as just text in a .txt file) stored on my SDCard on my Palm and want to be able to read in that file and in turn check the data. I'm not sure in which the best way to go about this using File Connection reader.
    I can already browse the SDCard via my app, but I want to be able to have decisions based on the data within the file, such as updating choicegroups based on the contents.
    Is there anyone out there with advise, or know's of link's to Tutorials/Sample Code/etc which might be of help?! Thanking you sooooo much in advance.
    Regards,
    Cam

    Thanks!
    Is there any kind of Import I should use with this code that with out might throw up these errors: Heh. I tried integrate that into my code you see, to a certain extent...!!
    Building "Project"
    h:\wtk\Project\src\Project.java:405: cannot find symbol
    symbol : variable read
    location: class javax.microedition.io.Connector
              FileConnection fc = (FileConnection)Connector.open("file:///SDCard/actype.txt",Connector.read);
    ^
    h:\wtk\Project\src\Project.java:406: java.io.InputStream is abstract; cannot be instantiated
                   InputStream is = new InputStream(fc.openInputStream());
    ^
    h:\wtk\Project\src\Project.java:407: cannot find symbol
    symbol : class StringBugger
    location: class Project
                   StringBugger sd = new StringBuffer();
    ^
    h:\wtk\Project\src\Project.java:411: cannot find symbol
    symbol : variable sb
    location: class Project
                   sb.append((char)ch);
    ^
    4 errors
    com.sun.kvem.ktools.ExecutionException
    Build failed
    Not cool :(!
    Thank's in advance!

  • Read from txt file and analyse data

    hi,
    i am having a problem for reading data from a text file and checking whether it is a integer or not.
    basically if i have a txt file with the following content:
    12 45 345 500 45.67684 33
    my output should be:
    12 45 345 500 invalid 33
    that means if there is a integer number in the file, the integer number will be printed on the screen BUT if there is anything else like a string or a double number, then "invalid" will be printed.
    how can i check what kind of datatype it is??
    i have the following code to start with:
    try
                BufferedReader in = new BufferedReader(new FileReader(FileName));
                String l = in.readLine();
                in.close();
            catch(IOException e)
                System.out.println("IO error");
                System.exit(0);
            }

    ok i have tried the following code:
            int index = 0;
            String[] arr = null;
            int nb = 0;
            try
                BufferedReader in = new BufferedReader(new FileReader(nameFile));
                String line = in.readLine();
                arr = line.split(" ");
                for(int i=0; i<arr.length; i++)
                    index = i;
                    nb = Integer.parseInt(arr);
    System.out.print(nb+" ");
    in.close();
    catch(IOException e)
    System.out.println("IO error");
    System.exit(0);
    catch(NumberFormatException e)
    System.out.print("invalid ");
    for(int j=index+1; j<arr.length; j++)
    nb = Integer.parseInt(arr[j]);
    System.out.print(nb+" ");
    which works perfectly fine for the following scenario:
    txt-file:
    12 45 345 500 45.67684 33
    output:
    12 45 345 500 invalid 33
    but what, if I have the following data in my txt file:
    12 45 345 500 45.67684 33 23.234 21
    then the output should be:
    12 45 345 500 invalid 33 invalid 21
    how can i solve this???

Maybe you are looking for