Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

Printing correctly an array of string...

Thread view: 
gbattine - 07 Jul 2006 09:59 GMT
Hi guys,
i'm a simple question and i need a good solution.
I have an array of byte which contents i have to print in my
application.
I read the array of byte into a string and knowning my original
format(; indicates the end of lines of my original txt file) i have
splitted this string into an array of string with split.

String lettura=new String(read);
String[] arraylinee=lettura.split(";");

Now there is my problem. I have to print correctly this array of
String.
Let's suppose it's made so:

string string string string(a whitespace separes 2 different values)
string double double double
string double double double

Now i have with split operation an array of 3 string elements but i
want to print correctly string and double.

I've done

System.out.println(arraylinee[0]);

for printing my first line that has only strings.
Now i have to develop some code that print correctly the 2th and 3th
lines that has a first string and other doubles. How can i do?
I've done

for (int i = 1; i < arraylinee.length; i++) {
                    String tot="";
    StringTokenizer sta=new StringTokenizer(arraylinee[i]);
    System.out.println(sta.nextToken());
/*i have skipped the first line that is already printed and i've
printed the first element of the other generic line,that is a
string*/            while (sta.hasMoreTokens()){
           Double.parseDouble(sta.nextToken());
           ...//what can i do for printing correctly the generic line?

                   }
}

Can you help me completing my code?
Please....i need your help
Gabstar - 07 Jul 2006 19:45 GMT
Not sure what the problem is here. All your tokens in the
StringTokenizer are already Strings, so you don't need to convert them
back to doubles to print them, just call 'println' for all of them.

Get back if I've missed the point...
gbattine - 08 Jul 2006 08:54 GMT
Excuse me but yesterday i was been a bit confused,
i try to be more clear....

Now i have an array of string and i want print them into a jsp result
page.
How can i do?
I use jsf, i ve created a bean with

private String[] arraylinee;

and i've created the setter and getter method.

Now i have to print this array,i think,with datatable.........can you
help me with code....thanks...

P.S. There is a possibility to do in a second moment a query on this
array of strings?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.