|
I now changed the logic.I am now taking each line in an array and checking
whether it contains \r ( do nothing if there)or replace (\n with \r\n).
Everything seems fine except the last replaecement .Can any body help .
int count=0;int index=0;
char seperator ='\n';
do
{
++ count;++ index;
index = swift.indexOf(seperator,index);
System.out.println (" index is " + index );
}
while(index!= -1);
System.out.println (" count is " + count );
//Extract string into array
String[] Substr = new String[count];
index = 0;int endIndex=0;
for (int i=0;i< count; i++)
{
endIndex=swift.indexOf(seperator,index);
if(endIndex==-1)
Substr[i]=swift.substring(index);
else
{
Substr[i]=swift.substring(index,endIndex);
}
if (Substr[i].contains("\r"))
{
System.out.println("No need of conversion");
System.out.println("Substring" + i + "is" + Substr[i]);
}
else
{
Substr[i].replace("\n","\r\n");
System.out.println("conversion done");
System.out.println("Substring" + i + "is" + Substr[i]);
}
index=endIndex+1;
}
//Display
for (int i=0;i<Substr.length;i++)
System.out.println("Substring" + i + "is" + Substr[i]);
|