aspose file tools*
The moose likes Beginning Java and the fly likes Tab character question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Tab character question" Watch "Tab character question" New topic
Author

Tab character question

Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
Hi all,

I am testing a parser object that is looking for strings in the following format and then put them in a map with the name as the key.

full name/temail/n. I want to create some test strings for the parser to test against. My question is should I manually put the tab in my test strings like String test = "My Name email@me.com'\n'"; or put the tab character in like String test ="My Name'\t'email@me.com'\n'"; or does it make a difference?

Thanks,

AMD
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

String hello = "hello\tworld";


[My Blog]
All roads lead to JavaRanch
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
Great thanks!

AMD
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
one more you have to put the \t in single quotes right?

String test="Hello'\t'World";

Thanks,

AMD
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Give it a try without:

System.out.println("Hello\tworld!");


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
Is that the same for the new line char too?

Thanks,

AMD
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Yup, see escape characters. Find yourself a good Java syntax reference book; it will be well worth your time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tab character question