get new line in StringBuffer within for loop
807601Mar 20 2008 — edited Mar 20 2008Hi every body,
I am trying to displaying the result on every new line. This works with System.out.println. But i am debugging with System.out.print. Because I want to check with which statement, I can get new line in StringBuffer.
One thing more \n works without for loop. But I do now know why it is not working within for loop. I will be thankfull if some body reply me because I am doing effort for last one day.
StringBuffer sb=new StringBuffer();
String txt=null;
String newLine = System.getProperty("line.separator");
for(int i=0;i<resultList.size();i++){
txt=(String) resultList.get(i);
System.out.print("Before new line:"+txt);
sb.append(txt).append(newLine);
//sb.append("\n"); sb.append("\\n");
//sb.append("\r\n");
//System.out.print("\nAfter new line:"+sb.toString());
}