
November 4th, 2012, 01:26 AM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 18
Time spent in forums: 6 h 17 m 32 sec
Reputation Power: 0
|
|
Well I managed to think of something myself. But I still need help.
The problem with this is every line that has a "{" in it is output twice one without the counter added and one with. I'd like someone to point out how I can make it work. Here is the section of my original code.
Code:
while(in.hasNextLine()) {
StringBuffer line = new StringBuffer(in.nextLine());
out.println(line);
for(int i = 0; i <line.length(); i++)
{
if(line.charAt(i)=='{')
{
counter++;
line.insert(i+1, counter);
out.println(line);
}
|