Skip the empty line while processing

Hi all
i'm reading from a file and i want to skip the empty line and process the line which has some data, but it seem that i doesnot process the "\n"as an empty line
for example i have the following data
i went to school
(empty line)
5 days a week
(empty line)
and i have the following code
    while((line = in.readLine() ) !=null) 
             if(line!="\n")
                  codes=line.split("   ");
                  }//if else
                  else
                  //do nothing
                  }

thanks dmbdmb
it works
may i ask another question
i have a file which has several sentences but the spaces between these sentences are not unique i.e some time 3 empty lines some times more or less
i have a code to make all the spaces just 1 between any sentece but it work with system.out.print but not with files any ideas
here is the code
        StringBuffer buffer=new StringBuffer();
        try{
            BufferedReader read=new BufferedReader(new FileReader(fname));
BufferedWriter br = new BufferedWriter(new FileWriter("111.txt"));
            String line=read.readLine();   
            boolean isNewLine=false;
            while(line!=null){
                if(line.length()==0 && !isNewLine){
                    buffer.append("\n\n");
                                   isNewLine=true;
                }//if
                else if(line.length()!=0){
                    buffer.append(line);
                    System.out.println("in ELSE");
                    isNewLine=false;
                }//else
                line=read.readLine();
            }//while
            br.write(buffer.toString());
             read.close();
       br.close();
        }//try
        catch(IOException ioe){
            ioe.printStackTrace();
        }

Similar Messages

  • Removing the empty line during Receiver FCC!

    Hi, Guys,
    I used file content conversion in receive FCC. My data type is like this:
    <TextFromSAP_DT>
    <FileName>
      <FileName>abc.txt</FileName>
    </FileName>
    <Record>
      <TEXT>dasfafaf</TEXT>
    </Record>
    <Record>
      <TEXT>qqqqqqqq</TEXT>
    </Record>
    <Record>
      <TEXT>fgfffff</TEXT>
    </Record>
    </TextFromSAP_DT>
    I need to get file name from <FileName> and output a flat file with the value in <TEXT>. But I always got an empty line at the file beginning. And I tried to move <FileName> to the end. And I got an empty line at the file end. My custom said they are having trouble to read the file with the empty line no matter it is in the beginning or end.
    I followed sample as link below but does not work. 
    https://wiki.sdn.sap.com/wiki/display/profile/2007/07/30/Removing%20the%20empty%20line%20during%20Receiver%20FCC!
    Does any body can give a help?
    Thanks a lot!
    Meiying
    Edited by: Meiying Yang on Aug 14, 2009 11:16 PM

    Hi Yang,
    You create the value udf GetFileName with one input value say a. Add this code:
    Imports: java.*;
    Add this code:
       //write your code here
    DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http:" + "/" + "/" + "sap.com/xi/XI/System/File", "FileName");
    conf.put(key, a);
    return "";
    Map like this:
    FileName --> GetFileName(udf) --> target_mt
    Map other fields like:
    Record --> Record
    TEXT ---> TEXT
    Save it and activate it. When you test in mapping you will get an error so dont worry. I go the error like:
    RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:Target_MT. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._TestFileName_ method file1$[abc.txt, com.sap.aii.mappingtool.tf3.rt.Context@32dcebf1]
    Dont worry about this activate and do the rest of the configuration.
    In your receiver communication channel for file name put as FileName and check the file name in adapter specific message attributes. Then test it and it should work and you will get the file with file name abc.txt. I tested the whole end to end scenario and I am getting the file name abc.txt and the output what you want. If you still could not get it send me a m ail to my i d from my business card. I will send you the screen shots.
    Regards,
    ---Satish

  • IPC:bute in the field catalogue while processing configuration or pricing i

    Hi,
    I get this error (Message Class: PRC_MESSAGES_EXT (Messages for Calling Public Pricing Modules), Message Type: E, Message Number 099, Message variables: Message variables 1-4: IPC:bute in the field catalogue while processing configuration or pricing in context spe.condmgnt.customizing.dba.imp.AttributeClassObjectManager.createAttributeClassAttributeClassObjectManager.java)
    when we ran IPC userexits. 
    We've added a field ZZPSTYV in the communication structure and modified the method to define this field like follows:
         public String[] determineRelevantAttributesForRequirement(
              boolean headerAttributes,
              int reqNo) {                         String[] relevantAttributes = new String[0];
         //Header?
         if (headerAttributes) {          }
         //Item
         else {
         //KOMP fields
         switch (reqNo){
              case 900:                              relevantAttributes = new String[] {"ZZPSTYV" };                                   break;
        return relevantAttributes;
    Running this code we get the above listed error.  Same error if we define unnecessarily a standard field, such as SOLD_TO_PARTY in place of ZZPSTYV.  
    Can anyone give us some advise as what we did wrong?  Appreciate it very much,
    Yanhui

    Hi Yanhui,
    Is it a item field?  Remember that mixed fields should be declared at the header in the IPC.
    Missing any other requirements?
    Cheers
    Andrew

  • How to skip the Inbound Delivery while updating LA confirmations via EDI

    Hi Experts,
    I have a requirement wherein I dont want to create Inbound Delivery automatically when updating the LA (or a copied Conf Cat of LA) confirmation via EDI.  When we are using the message type DESADV, LA confirmations are being updated, but simultaneously, the Inbound delivery also being created.  My client desires that Inbound Delivery should not happen and only LA confirmation should be updated via EDI.
    Is there anyway, by which we can skip the Inbound Delivery while updating the LA confirmations in the PO?
    Thanks in advance
    Regards
    Radha Krishna

    Hi Prabhaharan,
    Thanks for your quick response.
    My requirement is to have both AB and LA confirmations.  I have included these two in a new the conf control   So, your suggestion will not work.
    Is there any other way out to fulfill my requirement?
    Thanks & Regards
    Radha Krishna

  • SAP Version to be added in the subject line while posting a question.

    Hi,
    We all have been posting and answering thousands of questions on the SDN. Many times I have seen moderators asking the person who posted a question to use a correct and informative subject line.
    With respect to that, I would like to suggest the moderators to add a rule in the rules of engagement asking the users to provide the SAP Version in the subject line while posting questions.
    This way the person answering the question can appropriately provide information based on that version only and would save the time and effort of everyone.
    Example subject line can be :
    ECC 6.0 Function module xyz is not returning correct results.
    I would like to know the opinion of other users too on what they think about this suggestion.
    Best regards,
    Advait

    In theory - a very good idea.
    In practice - hard to enforce.
    On second thoght, it could be a required parameter. It might have the added benefit of dissuading questions from people who can't figure out which version they have
    Rob
    Edited by: Rob Burbank on Jan 16, 2009 3:56 PM

  • I accidentally hit the stop (x) button when the "empty secure trash" process was going on. Have I screwed up my computer? Can I continue the "Empty Secure Trash" later?

    I was cleaning my caches which was taking forever to clean up. (more than 4 hours). I accidentally hit the stop (x) button when the "empty secure trash" process was going on. Have I screwed up my computer? Can I continue the "Empty Secure Trash" later?

    Just restart your computer.   Then go to Finder menu and change 'Secure empty trash' to Empty trash.  
    Unless you work with state secrets you really don't need secure empty trash which takes seven times longer to do its job.    Empty trash is fine for all but the afore-mentioned secret files.

  • How can you avoid the empty line?

    hi all,
    i looked around quite a bit and didn't found an answer to this very common problem.
    i used this blog:
    Solution to the problem encountered using Variable Substitution with XI-SP12
    for using a dynamic filename.
    the problem i get is the file adapter create a empty line instead of the FILENODE which i need to be suppressed and not written to the file.
    is it possible?
    regards,
    roi grosfeld

    Hi,
    Well thats good question. you can't test it in test tab of mapping.
    It will give you exception like something below
    RuntimeException in Message-Mapping transformation: Runtime exception
    Here you can create the file name in Mapping either by using various APIs as well as Sender side filed values and can pass to the UDF that you will create for dynamic filename.
    File with same name will be created. This is specific to DynamicConfiguration class which deals with the values at runtime.
    Thanks
    Swarup

  • How to remove the empty lines in the generated XML?

    Hi, XML/JDOM experts,
    I used JDOM to generate an XML file in my exercise of comparing two xml files.
    I used a lot of times addContent()...
    The resuting xml is fine for its contents.
    But I don't like so many empty lines (or carriage return).
    Would you help to refine the result?
    Best regards,
    AG
    Sample results:
    <li delta:property="Modified">
    <code delta:property="Modified">
    <delta:NewValue>foreignObject</delta:NewValue>
    <delta:OldValue>text</delta:OldValue>
    </code>
    <svg xmlns="http://www.w3.org/2000/svg" width="6cm" height="45px" delta:property="Removed">
    <rect y="0" x="27px" width="110px" height="45px" style="fill: #C1FFFF" />
    <foreignObject width="120px" y="0" x="20px">
    <div xmlns="http://www.w3.org/1999/xhtml">
    <ul>
    <li>First item</li>
    <li>Second item</li>
    </ul>
    </div>
    </foreignObject>
    </svg>
    <svg xmlns="http://www.w3.org/2000/svg" width="9.5cm" height="1.2cm" delta:property="Added">
    <text y="33px" x="13px" style="font-family: helvetica; font-size: 14pt; fill: #FFAA00">A simple
    text in SVG
    </text>
    </svg>
    </li>

    The solution is to add
    outputter.setTrimAllWhite(true);
    Below is the sample code.
         FileOutputStream out = new FileOutputStream("delta.xml");
         XMLOutputter outputter = new XMLOutputter(" ", true, "UTF-8");
         outputter.setTrimAllWhite(true);
         outputter.output(doc1, out);
         out.close();

  • Help!! Can't see the indicating line while playing in Audition 3.0

    Hi all,
    It's my first post here.
    I now got a problem as the same time I re-installed Windows XP and Audition 3.0 some months ago: I can't see the indicating line (I don't know how to describe it, or moving line?) while playing in Edit View. So I wouldn't know where it play to. Anyone can help? Thanks from nusushika~ XD

    Hi mikromidas, thanks for replying~
    Yes, I have and AMD X2 3800+ processor.
    Do you mean the AMD X2 optimizer patch? I followed your instruction and everything seems good at this time. Thank you very much. XD

  • Getting empty lines while printing a form

    HI ,
    I am working with a smart form related to Physical inventory document.
    While displaying the items in the list, there is some issue.
    It is displaying 1 blank line, 1 line item, again 1 blank line, 1 line item..like that.
    It is displaying all the line items but with blank line after every line item.
    The balnk lines should n't be dispalyed.
    Could any one help me in this regard.
    Thanks in advance.

    Hi Nagapallavi V Adhikarla ,
    As Florian Kemmer said, there is a blank line in your table in the smartform.
    Before posting any question check throughly and post. Dont ask basic questions.
    Thanks & Regards,
    Rock.

  • Wanna skip exact number lines while reading a file file

    Hi all,
    I would like to skip exact number of lines while reading a text file.
    Let's say I wanna read this text file starting from line no N.
    And so I need to skip from fist line to N-1th line.
    Does anyone give me a way to do?
    Pls with a sample code if possible coz I am not familiar much to java. :P

    LineNumberReader class keeps track on line number for you. Sample that skip arg3 lines while copy arg1 file to arg2. Just sample no check, no cleanup.
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.LineNumberReader;
    public class Main {
        public static void main(String... args) throws Exception {
            if (args.length != 3)
                throw new IllegalArgumentException("Arguments: infile outfile line_from");
            LineNumberReader reader = new LineNumberReader(
                    new FileReader(new File(args[0])) );
            BufferedWriter writer = new BufferedWriter(
                    new FileWriter(new File(args[1])) );
            int readFrom = Integer.valueOf(args[2]);
            // skip first lines
            while(reader.getLineNumber() < readFrom) {
                if (reader.readLine() == null)
                    throw new IllegalArgumentException("Too few lines");
            // write tail
            String line = null;
            while((line = reader.readLine()) != null) {
                writer.write(line);
                writer.newLine();
            writer.flush();
    }

  • Reason behind the Vertical lines while iphone asleep

    Whenever my iphone was asleep for more than 10 or 15 min, some vertical lines appeared on the screen to last only a few seconds and then dissapear. I had no idea why this happened until a couple of minutes ago.
    I noticed that although they only lasted a few seconds, it was definitely a pattern.
    I now know what is the source of the problem.
    *I had configured my iphone to fetch data every 15 min (since my gmail account is not push). As soon as the phone was asleep, whenever it was time for the iphone to fetch data (while asleep), the vertical lines appeared. Now I know that it happens only when I have that option ON, since when I changed it to fetch manually, the lines did not show.*
    Any ideas why this happens? Is this a software or hardware issue?

    Hi. I recently updated to software vesion 2.0.2 and started to notice the vertical lines you describe. I had never noticed them before. I have spoken to Apple iPhone tech support and they say they have never heard of this issue. They have asked me to do a restore on the phone via iTunes to see if it is a software or hardware issue. If it still happens after restore they told me to go to Apple store to see about a possible replacement. I have tried the resore and so far I haven't noticed the lines but it is early days.
    By the way I have noticed the lines appear randomly and sometimes when I receive an email and get the audible signal I can see them.
    Let me know how you get on if you try to restore iPhone

  • Error message at the selection screen while processing screen logic

    Hi All,
      I need to show error message at the selection screen.
    I am calling the screen inside the START-OF-SELECTION, and processing the calculation and putting the data into i_final internal table. If internal table I_FINAL is empty I have to show error message saying ' DATA is empty' , this error message should be shown at the SELECTION SCREEN (Report input screen 1000) and provide the user to enter the input values once again.
    But whenever I am populating error message, I am getting a pop up to chose exit, and process is terminating.
    Since I am in the middle of the screen processing whenever I am giving a error message.
    Please let me know how can I populate error message without terminating the process while I was in the middle of the screen processing logic.
    Regards,
    Mahesh

    hi
    If u are trying to validate a field use
    AT SELECTION_SCREEN ON <field>
    if want to validate a block
    AT SELECTION SCREEN ON <block>
    If Universal Validation
    AT SELECTION SCREEN
    and display a 'E' Message inside the block.
    You can Enter Correct Value and start processing Forward.
    hope this will help.
    Regards
    Sumit Agarwal

  • Error for the fact table while processing the cube - attribute key cannot be found when processing

    Please help as I am new to SSAS and this is urgent requirement. This is a MOLAP cube and below is the error that I am receiving when processing the cube. The cube is set to Prrocess Full. Several similar errors are popped up for various dimensions.
    "Errors in the OLAP storage engine: The attribute key cannot be found when processing: Table: 'Fact_Table', Column: 'ID', Value: '1'. The attribute is 'Id'. Errors in the OLAP storage engine: The attribute key was converted to an unknown member because
    the attribute key was not found. Attribute Id of Dimension: 17 - Ves - PoC Cont from Database: DB, Cube: IPNCube, Measure Group: iSrvy, Partition: Partition1, Record: 1."
    Thanks in advance.

    Thanks for the recommendations David.
    It will be really great if you can clear some of my doubts:
    To my information, all the dimensions need to be processed first and then the fact table will be processed.
    So if the ID's are not present in the dimension tables, then it should not be present in the Fact table either.
    Here we found null values in the dimension table and the ID's were present in the Fact table. What might be the reasons causing such situation?
    Also how frequently the cube needs to be processed? Currently the ETL which processes the cube, is scheduled in a SQL Job Agent on hourly basis everyday. 
    Is there any possibilty that the cube might be under processing state and the SQL job for the next run getting executed trying to access and process the cube while it was still processing?

  • Want to change the BSEG-SGTXT while process through the transaction:FF_5

    Hi,
    I want to change the value in BSEG-SGTXT during the process through the transaction:FF_5.
    Can any one suggest any BADI or User Exit to update the SGTXT.
    Regards,
    Hema T

    Hi
    If your text is going to remain content based certain transaction types or text in the note to payee field then you can use the below functionality.
    Advantage no ABAP help required.
    Define Search String :
    Strg Name : Text
    Strng : Test (say if you want to find the word "test" in the incoming record. You refer the help doc on Search string for combinations)
    Mapping : (keep it blank)
    In Search string use :
    1)
    Company code :
    House bank id:
    Account id:
    Int algthm :  (if you are using any)
    Strg name: Check
    Target field: BDC Field name1 BSEG-SGTXT
    2)
    Company code :
    House bank id:
    Account id:
    Int algthm : (if you are using any)
    Strg name: Text
    Target field: BDC Field value1 "text that you want to enter in the Bseg- sgtxt field"
    3)
    Company code :
    House bank id:
    Account id:
    Int algthm : (if you are using any)
    Strg name: Check
    Target field: BDC Acct type1 0
    0: First line, posting area 1
    1: First line, posting area 2
    2: Second line, posting area 1
    3: Second line, posting area 2
    Regards
    Nikhil

Maybe you are looking for