but i rather get as cdaccenter infoway id 24 fname john.. so can somebody help me out with this.. here is my code.. your suggestions are welcome..
First off, you shouldn't post so much code, especially when 90% of it is totally unrelated to your problem.
It's not totally clear what you're trying to do, but it sounds like you have a String consisting of multiple tokens and you want to display each token on its own line. If that's the case, look into String's split() method.
I accept that i should not post such long and hectic codes but in my last post when i posted only a part of code somebody got upset.. so i thought that if i post whole code somebody might copy paste it and run it as a whole so as to get what exactly i am getting.. being new i listen everybody saying here.. also i am new to java... so keep on asking even silly things... but i really need your help.. thanks for telling me about split().. but i really find it difficult to get used here... can you explain it even more??
yogesh raipure wrote:thanks jeff...
I accept that i should not post such long and hectic codes but in my last post when i posted only a part of code somebody got upset.. so i thought that if i post whole code somebody might copy paste it and run it as a whole so as to get what exactly i am getting..
Yes, you ideally would post code that anybody could copy, paste, compile, run, and get the same results as you. However, that code should only include what's directly relevant to the problem at hand. It should be an SSCCE. This might mean you have to create a whole new program, but you shouldn't hesitate to do so if that's what it takes to get the message across without anything extra.
thanks for telling me about split().. but i really find it difficult to get used here... can you explain it even more??
I can't explain it more if you don't tell me what you don't understand about it. You know that you need to ShowSomeEffort(⇐click) and TellTheDetails,(⇐click) right? So I assume you looked it up in the javadocs, and, if they still left you puzzled, that you googled for java String split examples, and that you then tried it yourself. So, after doing that, what specific problems or questions do you still have?
William P O'Sullivan wrote:Of course, you will get one line only.. you only write one line and it is built with:
If you do not want to use split() then you need to do something like:
where BREAK is defined using the System properties for the underlying OS line break character(s).
@Yogesh: William raises a good point here. There are two different approaches.
1) You are building the String yourself, and you have total control over how it's built, and you don't ever need it to be a single line. If this is the case, then you can just construct it with the line breaks in the String from the beginning.
2) You're not building the String yourself--it comes from somewhere else; or you are building it, but you have to build it as a single line, etc. If this is the case, then split() would be my first advice, and if you can't or don't want to use that, then you'll have to iterate over the characters of the String yourself, building a new String as you go (with StringBuilder.append()), and inserting line breaks at the appropriate places.