• Post Reply Bookmark Topic Watch Topic
  • New Topic

String formate  RSS feed

 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have large text in a String what i want is i want each character separate from that string that i can get with String method toCharArray() but one thing i want is where there is space it shows \b not ' ' where there is TAB it shows \t not ' ' where there is enter it shows \n etc how i can attain is there any way to get them with if else ??? i mean

etc

thanks in advance
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A space converted to \b requires two characters ('\' and 'b') so you cannot use a character array, you need to use a String array.
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:A space converted to \b requires two characters ('\' and 'b') so you cannot use a character array, you need to use a String array.


but thats not my core problem ..... problem is as it is.......
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
akhter wahab wrote:
but thats not my core problem ..... problem is as it is.......


You have lost me! You can't fit two characters into one character which you seem to now recognise so I really don't know what you are asking.
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:
akhter wahab wrote:
but thats not my core problem ..... problem is as it is.......


You have lost me! You can't fit two characters into one character which you seem to now recognise so I really don't know what you are asking.


i have large text in a String what i want is i want each character separate from that string that i can get with String method toCharArray() but one thing i want is where there is space it shows \b not ' ' where there is TAB it shows \t not ' ' where there is enter it shows \n etc how i can attain is there any way to get them with if else ??? i mean

 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the point of just re-posting 80% of your original post? It seems to me like you need to use the String.replace() on the original String for each character you need to change! No need to convert to a char array!
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:What is the point of just re-posting 80% of your original post? It seems to me like you need to use the String.replace() for each character you need to change!


how will i identify TAB and line break from give Char Array ??
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tab = '\t'
Line break = '\n'
Return = '\r'

or you can use the Unicode representation \uxxxx where the xxxx is the Unicode value for the tab, line break, return etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!