Overread lines in input file

Hi guys, i really hope u can help me.
We are trying to read a file via FTP which looks like this:
Dataname 639 539 00;;;;
Pos. :;Var;Name;GHNr.;Desc
4;1;ABB;639 539 00 9960/4;
5;1;ABC;639 539 00 9960/5;
Machine;;;;;
Porsche;;;mark;;
9 9 9   2 4 9   0 0   9 9 6 1;;;;;
Us.: 12.10.00 Em;;Nr.: ;6 3 9   5 3 9   0 0   9 9 6 0     ;;
So for me it is hard to read the data because the empty lines i don't need and for some results i have to read numbers at special positions (like the last devided with space).
Is there any chance to read this file this kind of dynamically?!
br Jens

I doubt that would be possible with the default File Adapter. You can however read every line and use User Defined Functions to extract the information you require.

Similar Messages

  • Converting a single line in Input file

    Hi Experts,
    I tried searching the blogs and wiki in sdn. but couldnt able to find out.
    Can anyone help in providing the blog for converting the input xml file which is provided only in one line.
    and the output has to be according to the xml format ( every tag in different line ).
    Thanks in advance
    Divya

    Hi Experts,
    I tried searching the blogs and wiki in sdn. but couldnt able to find out.
    Can anyone help in providing the blog for converting the input xml file which is provided only in one line.
    and the output has to be according to the xml format ( every tag in different line ).
    Thanks in advance
    Divya

  • Read lines from text file to java prog

    how can I read lines from input file to java prog ?
    I need to read from input text file, line after line
    10x !

    If you search in THIS forum with e.g. read lines from file, you will find answers like this one:
    Hi ! This is the answer for your query. This program prints as the output itself reading line by line.......
    import java.io.*;
    public class readfromfile
    public static void main(String a[])
    if you search in THIS forum, with e.g. read lines from text file
    try{
    BufferedReader br = new BufferedReader(new FileReader(new File("readfromfile.java")));
    while(br.readLine() != null)
    System.out.println(" line read :"+br.readLine());
    }catch(Exception e)
    e.printStackTrace();
    }

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • How to find number of lines in an input file.

    Hi,
    Can someone tell me, if there is a way to find out the number of lines in an input file. I do not want to read line by line and then count the number of lines read.

    Then how do you think a program could determine the amount of lines in an input file? How does a human know how many lines are on a page? You're going to have to count the items that separate two lines to know how many lines are in your file.
    Either read line by line and count the amount or read char by char and count the number of '\n' occurences instead.
    If you have control over writing the input files, however, you can make this better. Write a header in the file that specifies the amount of lines in it. The first line of your file will then hold a number that represents the amount of lines in the file, so you need only read the first line to know how many lines are in your file.

  • How to upload  schedule line from flat files to sap file

    dear all,
    i want to upload the schedule lines from flat files to sap schedulle lines
    but the flat files have 15 schedule lines and the data is as per date
    so how to upload that and the fields available in flat files are more than the sap screen
    we are having more than 6 items
    and 15scedule lines its abt 90data to be upload
    for one customer in every 15 day
    so how to do this
    is there any direct use in functional side
    with out the help of any abap
    but my user will do it
    so he need a permanent solution
    with regards
    subrat

    Hi Subrat ,
    u can upload the data either ( Master /Transaction) data with the help of lsmw. for that all u need to do is go through the lsmw and do it. in that u can go Batch input recording/ BAPI/ IDOC any of that. here i am sending the LSMW Notes go through it and do the work.
    once u create the LSMW project then u can ask the data from user or u can explain the user about the program and can run the flat file to upload the data.
    if u require LSMW material Just send me blank mail from u. my mail id is [email protected]
    Reward if Helpful.
    Regards,
    Praveen Kumar.D

  • How to get characters from a line in a file ?

    Hello Everybody ,
    I am able to read the lines from the file using readLine( ) method.
    But i do not want to read anything that comes after the character '#'
    Any thing that follows a '#' character is considered as a commet in my case.
    The contents of my input file are,
    #Character mappings for Japanese Shift-JIS character set
    #ASCII character Mapped Shift-JIS character
    m 227,128,133 #Half width katakana letter small m
    n 227,128,134 #Half width katakana letter small n
    o 227,129,129
    p 227,129,130
    q 227,129,131
    r 227,129,132
    s 227,129,133
    t 227,129,134
    u 227,129,135
    v 227,129,136
    w 227,129,137
    x 227,129,138
    y 227,129,139
    z 227,129,142
    My code to read the contents of the file is,
    import java.io.*;
    class Read
    public static void main(String s[])
    try{
    int i=0,j,l;
    BufferedReader in=new BufferedReader(
    new InputStreamReader(
    new FileInputStream("Character.txt")));
    String []str=new String[100];
    while(true)
    str=in.readLine();
    if(str[i]==null) break;
    System.out.println(str[i]);
    i++;
    catch(Exception e)
    e.printStackTrace();
    System.out.println(e);
    How do i store the values within a line in the file
    to two different variables
    Like say,
    I read the line
    i get the character 'm' store it in a variable say, char ch='m' ;
    and the corresponding value 227,128,133 in a String variable.
    String str="227,128,133";
    Please offer some suggesstions and help me out .
    Any suggesstions would be welcome and very useful.
    Thanks and regards
    khurram

    It depends on whether the format of the file will ever change. If the "rules" regarding the structure of the file are predictable, then it's fairly simple.
    In the sample file, if we assume that anything that starts with # should be ignored, and all relevant lines begin with single char, followed by three comma separated integers; then you can just do the following (haven't tested this)
    import java.io.*;
    class Read
         public static void main(String s[])
              try{
                   // Create a Map to store the results..
                   Map data = new HashMap();
                   // We will store the actual values in an array
                   int[] values = null;
                   // Each valid line has a character
                   char theChar;
                   // Temp storage for the integer values
                   String[] strValues = null;
                   BufferedReader in=new BufferedReader(
                   new InputStreamReader(
                   new FileInputStream("Character.txt")));
                   String str=null;
                      while(true)
                        str=in.readLine();
                        if(str==null) break;
                        // trim to remove any spaces
                        str = str.trim();
                        theChar = str.charAt(0);
                        if(theChar != '#') {
                             // not a comment
                             // Split to get the int
                             strValues = str.substring(1, str.length()).split(",");
                             // We only want the first 3 tokens
                             values = new int[3];
                             for(int i = 0; i < values.length; i++) {
                                  values[i] = Integer.parseInt(strValues);
                             // Now, add the results to the map
                             data.put(String.valueOf(theChar, values);
                             System.out.println(str);
              catch(Exception e)
                   e.printStackTrace();
                   System.out.println(e);
    This will leave you with a Map of the character mappings, keyed on the String value of the character (just because you can't store a char in a Map)

  • The file size of selected file in input file control is shown as 0 for multiple file selection in Safari 5.1

    The file size of selected file in input file control is shown as 0 for multiple file selection in Safari 5.1. If you select single file, then it is able to return file size correctly. However, if you select multiple files, then the file size of each of the selected file is always returned as 0 from javascript. This works correctly in Safari 4.0 but it does not work in Safari 5.1.
    How do I get the correct file size in Safari 5.1 ?

    If you want to post (or send me) a link to the lrcat file, I'd take a look at it for you, and give you a break-down what's consuming all the bytes. But it might be fun to learn how to do that yourself (e.g. using SQL). I use SQLiteSpy, but other people have their favorites.. (or you can use a command-line client if you prefer..). One way: just run "drop table "{table-name}" on each table then look at filesize (do this to a copy, not the real thing).
    Anyway, it's hard to imagine keywords and captions etc. taking much of the space, since even if you had 1000 10-character words of text metadata per photo average that still only adds up to 117MB, which isn't a substantial portion of that 8G you're seeing occupied.
    Anyway, if you've painted the heck out of most of them and not cleared dev history, that'll do it - that's where I'd put my money too...
    One thing to consider to keep file-size down:
    ===================================
    * After reaching a milestone in your editing, take a snapshot then clear edit history, or the top part of it anyway (e.g. leave the import step), using a preset like:
    Clear Edit History.lrtemplate
    s = {
        id = "E36E8CB3-B52B-41AC-8FA9-1989FAFD5223",
        internalName = "No Edit",
        title = "Clear Edit History",
        type = "Develop",
        value = {
            settings = {
                NoEdit = true,
            uuid = "34402820-B470-4D5B-9369-0502F2176B7F",
        version = 0,
    (that's my most frequently used preset, by far ;-})
    PS - I've written a plugin called DevHistoryEditor, which can auto-consolidate steps and reduce catalog size - it's a bit cumbersome to use a.t.m. but in case you're interested...
    Rob

  • Need some Help ( formating strings vs formatting input files)

    I have a program that reads in a text file and stores each line as a string. The input file has no delimiters and varying amounts of white space. The problem is, I am trying to display each line of the file the same way. Here is an example of what the string looks like when I read it in and then output the strings.
    (I am using the underline to represent white space just in this message post.)
    1.Fred Smith____GA_____23_______42______23.5_____3____5
    2.Jon Doe____SC___42_______3_______39.2_____6_____12
    Now here is is how I would like the output to look like.
    1.Fred Smith_______GA_______23_____42_____23.5_____3_____5
    2.Jon Doe__________SC_______42_____33_____39.2_____6_____12
    Any thoughts or insight on how to achieve this would be great. Thanks for the time.

    Hi, before I'd do anything more complicated, I'd replace some spaces with tabs and see if that does the trick.
    Cheers, HJK

  • Input file should be deleted only after the output file is successful.

    Hi Experts,
    Could you pleas solve the below issue.
                           In  a file to file scenario, the input file will be picked from a directory location and after processing output file will be placed in the output directory location specified in the receiver communication channel.
    In the sender communication channel for the scenario mentioned above, if the processing mode is given as delete, the input file will be delete as soon as the file was successfully read by the adapter, but this will not ensure that the file processing is complete and the output file is being created.
    If we have a scenario in such as way that the input file should be deleted from the input folder only if the complete process is successful and the output is generated. how can we achieve this functionality?.
    And one more thing if we got the successful output the output file should be placed in one folder. and the if the output file is having errors it should be placed in other folder.

    Hi,
    In Receiver communication channel I have used the below command in Run Operating System
    .And I have kept the processing mode of sender communication channel as test.
    cmd.exe: /C "del /Leela/test.xml"
    You are running the comman line program configured in the receiver File Adapter,but in command line you mentioned the Sender File Folder , So i guess it's not getting processed.
    Try this:
    Try to run the command line in the Sender File Adapter Side
    "Place this in " --> Run OS Command After Message Processing.
    Hope this would work and get in parrallel with u r requirement.
    regards
    Srini

  • How to know a line of text file is ending with line feed or return?

    hi all, i have a program that read log file that generated by other service (apache http server for example), i want to know that each line is ending with "\r", "\n" or "\r\n" so i can skip them in the next time, like this:
    int char_counter=0;
    BufferedReader reader = new BufferedReader(new FileReader(logFileName));
    while((line=reader.readLine())!=null){
           char_counter+=line.length()+x_value;
    }and the next time read the log file, i will skip all the lines that read in previous time.
    BufferedReader reader = new BufferedReader(new FileReader(logFileName));
    reader.skip(char_counter);
    while((line=reader.readLine())!=null){
           char_counter+=line.length()+x_value;
    }with x_value is 1 or 2 depended on line end with "\n" or "\r\n".
    so, how to know which is the char line ending with?
    Edited by: secmask on Feb 21, 2009 5:46 AM

    Alright, the BufferedReader method readLine() reads all text until it finds a \n character. And then next time you call it it will automatically continue from where it left out.
    try this out it should show it as an example
    import java.io.*;
    public class readLineTest {
        static FileOutputStream filename;
        static BufferedReader input;
        public static void main(String[] args)
            try
                filename = new FileOutputStream("logFile.txt", false);
            catch (IOException e)
                //blank
            PrintStream output = new PrintStream(filename);
            output.println("this is the first line");
            output.println("this is the second line");
            output.println("this is the third line");
            try
                input = new BufferedReader(new FileReader("logFile.txt"));
            catch(IOException e)
                //blank
            for(int i = 0; i < 3; i++)
                try
                    System.out.println(input.readLine());
                catch(IOException e)
                    //blank
    }

  • Input file size limition in File Reader Adapter

    Hi,
    We have a File Read Activity(using File Reader Adapter) which works on a Polling model. Whenever a input file is found in a designated directory it invokes our BPEL web service. During load testing we found out that if input file size exceeds 7 MB then we get "insufficient heap space" error. We found a reference to this size limitation in http://download.oracle.com/docs/cd/E11036_01/integrate.1013/b28994.pdf which has below lines..
    "Files that are 7MB or larger in size cannot be delivered. As an alternative, you can debatch large files (if they have multiple messages), and publish these files in messages of size less than 7 MB. This alternative is applicable only to structured files (comma-delimited or fixed position), which contain more than one message. It is not applicable to binary or XML files."
    Our customer will have the data in XML format and the size of the files will be pretty huge(running into 49, 69 MBs). Do we have any workaround here or we are left with no option but to ask the customer to split the files and load it? The later option is currently difficult one for the customer since when split there is a possibility of XML becoming invalid. Any pointers in this issue is appreciated.
    Thanks!
    Balaji

    Hi,
    BPEL can not process more than 7 MB size xml structred file. but,debatching will work for xml files also provided if the file has repeated multiple structures (means multiple repeated root elements).
    Regards,
    Dhanumjay

  • File adapter input file format

    Here the communication scenario is as follows: read a file and send a message via XI to an inbound interface.
    A file adapter service has been defined. Message protocol 'file content conversion' has been chosen for the file adapter service. Next the file format has to be defined in communiction channel settings.
    Is it possible to define the input record structure in the file to be red itself?
    The first line will list all column names. The data records will follow in line two up till end of file.
    Regards
    Klaus

    Now I can add some more information to the facts.
    In XI 2.0 the adapter engine was used to connect the integration engine to external systems. The adapter engine converted input file contents to a XML message. The structure of the records in the input file has to be defined. There was one option to read this structure from the first line of the file itself. This option was called 'fromFile'.
    Now the current situation in XI 3.0 is that the integration engine reads the input file. Conversion of file contents is still available but the option to read the record structure from the input file doesn't exist anymore.
    Does anybody know whether I am right and this functionality isn't available anymore or how to achieve the desired system function in XI 3.0.
    Regards
    Klaus

  • New lines in a file

    I'm trying to find a good way to get new lines in a file, and while this works it also uses 100% CPU and is driving me nuts. At least the profiler says this is .run is using the most, and taskmanager gives it 100%. The file name changes every day.
    package net.st0rm.ss.loghandlers;
    import java.io.*;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Timer;
    import java.util.TimerTask;
    import net.st0rm.ss.Log;
    import net.st0rm.ss.gamecmdhandlers.GameCommandHandler;
    import net.st0rm.ss.irc.IRC;
    public abstract class LogHandler {
         public static ArrayList<GameCommandHandler> gameCmdHandlers = new ArrayList<GameCommandHandler>();
         private BufferedReader reader = null;
         private File directory = null;
         private LogReadThread thread = null;
         private String thisLine = null;
         private boolean skip = true;
          * Time to wait between reads
         private Long delay = 100L;
          * Creates a new instance
          * @param directory Directory of the files used
          * @param skip Should the reader skip lines already existing?
         public LogHandler(File directory, boolean skip) {
              this.directory = directory;
              this.skip = skip;
         public String getFileName() { return ""; };
         private class LogReadThread extends Thread {
              public boolean stop = false;
              public void run() {
                   Calendar c = Calendar.getInstance();
                   c.set(Calendar.HOUR_OF_DAY, 23);
                   c.set(Calendar.MINUTE, 59);
                   c.set(Calendar.SECOND,59);
                   StringBuilder sb = new StringBuilder(1000);
                   new Timer("Restart Timer").schedule(
                             new TimerTask() {
                                  public void run() {
                                       try {
                                            Thread.sleep(3000);
                                       } catch (InterruptedException e) {
                                            // TODO Auto-generated catch block
                                            e.printStackTrace();
                                       IRC.getInstance().msg("Restarting reader \"" + this.getClass().getSimpleName() + "\" for the new day.");
                                       LogHandler.this.restartReader();
                             ,c.getTime(), 3600000*24);
                   try {
                        reader = new BufferedReader(new FileReader(directory.getAbsolutePath() + "/" + getFileName()));
                        if (skip) while ((reader.readLine()) != null);
                        while (!stop) {
                             try {
                                  Thread.sleep(delay);
                             } catch (InterruptedException e) { System.out.println("Thread Interupted!"); }
                             while ((sb.append(reader.readLine())).toString() != null) { onNewLine(sb.toString()); sb.delete(0, sb.length()); }
                        reader.close();
                   } catch (IOException e) {
                        Log.log(e);
          * Call to re-start the file stream
         public void restartReader() {
              if (thread != null) thread.stop = true;
              thread = new LogReadThread();
              thread.start();
          * Called when a new line is added to the file
          * @param line The line added
         public void onNewLine(String line) { }
    }

    I don't know what anybody can say other than "debug and profile your code".
    It's weird that you have a Thread.sleep in the run method of a TimerTask. Why not just change the scheduling of the task?
    This:
    while ((sb.append(reader.readLine())).toString() != null) {
        onNewLine(sb.toString());
        sb.delete(0, sb.length());
    }(reindented to make it easier to read) is fishy. Even when you reach the end of reader's input, I think it will just loop forever. That's because appending null to a string buffer and calling toString results in the string "null", not the value null. So that while loop will never end.
    Good luck.

  • Having Troubles Gettin Lines Of Input!?!?!?!!?

    I'm trying to build a command line application (named Assemble) which will read (from standard in) a tagged "discussion" stream and print a (somewhat) organized version of the tagged part of the discussion (to standard out).... but i'm having trouble getting multiple lines of input.. i tried a while statement that looked like this... while ( (input = in.readline()) != null ) and all i got was every other line of input to get displayed to the screen or to a file... how can i fix this??? i had the while statement above input = in.readLine();
         BufferedReader in = new BufferedReader (new InputStreamReader( System.in ));
         String input;                
         input = in.readLine();
         System.out.println( input );

    thanks.. i have the input coming in.. but how can i redirect input to output within the program.. i'm trying to move the input lines to either a file called head.txt, body.txt, or foot.txt... once the files are in there.. i want to read them out to the screen... how can i do this? at the moment..i'm moving them just to the screen..
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    public class Assemble
    public static void main(String args[]) throws IOException
    if (args.length > 0)
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("Assemble.class is a small program that");
    System.out.println("takes in as input a body of text and then");
    System.out.println("outputs the text in an order according to");
    System.out.println("the tags that are placed in the input.");
    else
    System.out.println("");
    System.out.flush();
    BufferedReader in = new BufferedReader (new InputStreamReader( System.in ));
    String input;
    while (true)
    input = in.readLine();
    if (input == null)
    break;
    else if ( (input.compareTo("<HEAD>")) == 0)
    do
    input = in.readLine();
    if ( (input.compareTo("</HEAD>")) != 0)
    System.out.println(input);
    while ( (input.compareTo("</HEAD>")) != 0);
    else if ( (input.compareTo("<BODY>")) == 0)
    do
    input = in.readLine();
    if ( (input.compareTo("</BODY>")) != 0)
    System.out.println(input);
    while ( (input.compareTo("</BODY>")) != 0);
    else if ( (input.compareTo("<FOOT>")) == 0)
    do
    input = in.readLine();
    if ( (input.compareTo("</FOOT>")) != 0)
    System.out.println(input);
    while ( (input.compareTo("</FOOT>")) != 0);

Maybe you are looking for

  • How can I print ONLY the active document?

    Whenever I go to File/Print the darn PSE 9 program sends all of the working files in the bin to the printer. I've searched online for 2 hours now looking for an answer. I like to work with having several to many files in the 'bin' and prefer to only

  • BAPI_PR_CREATE Extension Issue

    Hi I am using BAPI_PR_CREATE to upload Purchase Requisition Create data for ME51n Transaction. Here there is screen Enhancement has been added to ME51n. When Iam uploading data through BAPI_PR_CREATE the below error message is been shown in RETURN st

  • Type of cable quest

    what kind of cable do I need to connect my home theater to my Audigy 2 ZS using the digital out? I tried with a Red & White RCA to Stereo jack and it didn't work, I used only one (red or white) to connect it to the hometheater in "digital in". Any he

  • What currently available charger will power a 2005 Mac mini G4?

    I have a late 2005 Mac mini and need to replace the power adaptor - any idea which of the currently available models will work or where I can get a non-apple version?

  • Trouble using FaceTime on iPhone 5

    Trouble connecting FaceTime on iPhone 5