I have a method that is called when my program recieves messages from a server.
It is given a string(the message)
I am attempting to seperate the string with "+" characters in order to transmit more efficient messages.
Scanner scan = new Scanner(stringVar);
scan.useDelimiter(" + ")
I then proceed to print out each seperated string on a new line.
if(scan.hasNext())
{
do
{
System.out.println(scan.Next());
}
while(scan.hasNext())
}
else
{
scan.close();
}
For some reason, either of these processes is broken as the whole input string is printed in one line!
What i want:
Line1
Line2
Line3
Line4
What happens:
Line1 + Line2 + Line3 + Line4
Is there any thing that i am doing wrong?
Also if there is a more efficient way of doing this...

New Topic/Question
Reply



MultiQuote




|