Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to separate words by using tab in Java ?

Reply
Thread Tools

How to separate words by using tab in Java ?

 
 
tobleron
Guest
Posts: n/a
 
      10-21-2008
Hi, I have a data like this :

String sample = "blaa blee bliii bloo bluu";

These words were separated by tab (not space). I want to classify them
into :

String word1 = "blaa";
String word2 = "blee";
String word3 = "blii";
String word4 = "bloo";
String word5 = "bluu";

How to do that ? Please help. Thank you in advance.

Note : I know how to use scanner. I also know that new line is "\n".
But I don't know about tab. Is it "\t" ??
 
Reply With Quote
 
 
 
 
Andreas Leitgeb
Guest
Posts: n/a
 
      10-21-2008
tobleron <(E-Mail Removed)> wrote:
> Hi, I have a data like this :
> String sample = "blaa blee bliii bloo bluu";
> These words were separated by tab (not space).
> I want to classify them into :
> String word1 = "blaa";
> String word2 = "blee";
> String word3 = "blii";
> String word4 = "bloo";
> String word5 = "bluu";


> How to do that ? Please help. Thank you in advance.
> Note : I know how to use scanner. I also know that new line is "\n".
> But I don't know about tab. Is it "\t" ??


Yes, it is, (as can be seen by following one of the many links
to "Pattern" from Scanner's javadoc, and reading there.)

Another, perhaps simpler option for you could be using String.split:
String[] words = sample.split("\t");
now: words[0]=="blaa", words[1]=="blee", ...

finally, if really necessary, assign to separate variables:
String word1=words[0], ... , word5=words[4];

 
Reply With Quote
 
 
 
 
tobleron
Guest
Posts: n/a
 
      10-21-2008
@lew and Andreas,

Thank you for your help. It works now.
 
Reply With Quote
 
FrenKy
Guest
Posts: n/a
 
      10-21-2008
Lew wrote:
> tobleron wrote:
>> Hi, I have a data like this :
>>
>> String sample = "blaa blee bliii bloo bluu";
>>
>> These words were separated by tab (not space). I want to classify them
>> into :
>>
>> String word1 = "blaa";
>> String word2 = "blee";
>> String word3 = "blii";
>> String word4 = "bloo";
>> String word5 = "bluu";
>>
>> How to do that ? Please help. Thank you in advance.
>>
>> Note : I know how to use scanner. I also know that new line is "\n".
>> But I don't know about tab. Is it "\t" ??

>
> <http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.6>
>
> One minute of research. JLSIYF.
>
> Read the Java tutorial(s):
> <http://java.sun.com/developer/onlineTraining/>
>


JLSIYF??? What is that... Google does not know
Java Language Specification In Your Face???
 
Reply With Quote
 
King_Alex
Guest
Posts: n/a
 
      10-22-2008
On Oct 22, 4:48*am, Lew <(E-Mail Removed)> wrote:
> Lew wrote:
> >> <http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.....>

>
> >> One minute of research. *JLSIYF.

> FrenKy wrote:
> > JLSIYF??? What is that... Google does not know
> > Java Language Specification In Your Face???

>
> Oh, come on. *Really?
>
> You got the JLS part. *Now relate the rest to "GIYF" and it should all come clear.
>
> One question mark is sufficient to indicate an interrogative.
>
> --
> Lew


I didn't get it... can you help?

===================================
Meet all Java developers, join the community, help the developers who
are new to Java www.techcubetalk.com
===================================
 
Reply With Quote
 
RedGrittyBrick
Guest
Posts: n/a
 
      10-22-2008

King_Alex wrote:
> On Oct 22, 4:48 am, Lew <(E-Mail Removed)> wrote:
>> Lew wrote:
>>>> <http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3....>
>>>> One minute of research. JLSIYF.

>> FrenKy wrote:
>>> JLSIYF??? What is that... Google does not know
>>> Java Language Specification In Your Face???

>> Oh, come on. Really?
>>
>> You got the JLS part. Now relate the rest to "GIYF" and it should all come clear.
>>
>> One question mark is sufficient to indicate an interrogative.
>>
>> --
>> Lew

>
> I didn't get it... can you help?
>


http://www.google.com/search?q=GIYF

--
RGB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:27 AM
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:26 AM
Using separate classpaths for separate classes? Frank Fredstone Java 1 06-27-2006 06:46 AM
How to use several separate classes (separate files) to be executed in one class (another file) EvgueniB Java 1 12-15-2003 01:18 AM



Advertisments