2

I want to display the data from an EMAIL_TEXT database column splitting the columns at a defined character. For some reason my results are only printing the first line up to where I split the string skipping the rest of the lines. Here is the data I wish to split after every "|".

Here is a sample of the database column to be split.

TEXT TEXT Line1 |

TEXT TEXT Line2 |

The results printed are:

TEXT TEXT Line1

The desired results are :

TEXT TEXT Line1  
TEXT TEXT Line2

Here is my Java Code:

String[] result = EMAIL_TEXT.split("\\|");
String subject="";
BufferedReader br;
BufferedReader brCSS;
FileReader fr;
FileReader frCSS;
String content="";
String CssContent="";
Document document1=null;
String FILEPATH = get(Fields.In, "FILEPATH").getString(r);

String filePathArray []=FILEPATH.split(",");
String mainContents = "";
int j;
try{
    for(j=0;j<filePathArray.length;j++)
    {
        subject= get(Fields.In,"EMAIL_SUBJECT").getString(r);

        fr=new FileReader(filePathArray[j]);
        br= new BufferedReader(fr);
        String s;
        content = "";
        String c;
        if(mainContents.contains("header-image.jpeg")!=true)
        {
            mainContents += "<img src=header-image.jpeg>";
        }
        content = content + result[j];
        while(( s=br.readLine())!=null)
        {

            content=content+s;

        }


    }
5
  • Can you take a sysout of EMAIL_TEXT and post it here Commented Sep 17, 2014 at 15:49
  • 2
    Honestly I don't think the rest of the code is relevant other than the EMAIL_TEXT.split(); Commented Sep 17, 2014 at 15:56
  • 1
    Is filePathArray the same length as result? You are using the same index j in both filePathArray[j] and result[j]. Commented Sep 17, 2014 at 15:59
  • No they are of different lengths with the result being a much longer string. Commented Sep 17, 2014 at 16:05
  • You most likely want to use nested for-loops then. One loop for result, and one for filePathArray. But it's hard to tell, when I don't know how you want to put together the text from the arrays and files. Commented Sep 17, 2014 at 16:14

1 Answer 1

1
String[] result = EMAIL_TEXT.split("\\|");
for(String s:result){
   System.out.println(s);
}

you have all the text inside result array... just loop through them to get all of the lines...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.