marcelo gobelli

Greenhorn
+ Follow
since Aug 08, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by marcelo gobelli

Rob Prime wrote:No, but Be Forthright When Cross Posting To Other Sites.



trying to learn java. any help is appreciated.
14 years ago

Darryl Burke wrote:On the Sun/Oracle forums last week.
http://forums.sun.com/thread.jspa?threadID=5433217



yes, and if you look at "in reply to #8" I am still waiting for an answer. Is it incorrect to post the same issue to both forums?
14 years ago
I have this string:

String s = "########## \r\n# #########\r\n";

I want to run length encode the results. I am successful at encoding it:
10#6-|#5-9#|. I am using a delimeter here: "|". I am also using the replace ('-') for whitespace

I need help with this: how to suppress the trailing whitespace if there is only whitespace before the delimeter. I want my output to be:

10#|#5-9#|

I have a method that does the encoding and do not want to do it with a regex in the parser. This is the method:

public String encode(String input) {
StringBuffer dest = new StringBuffer();

for (int i = 0; i < input.length(); i++) {
int runLength = 1;
while( i+1 < input.length() && input.charAt(i) == input.charAt(i+1)

) {
runLength++;
i++;

}
if (runLength == 1) {
dest.append(input.charAt(i));
}
if (runLength == 2){
//dest.append(runLength);
dest.append(input.charAt(i));
dest.append(input.charAt(i));
}

if ((runLength > 2) {
dest.append(runLength);
dest.append(input.charAt(i));
}


}
return dest.toString();
}


Thanks for the help.
14 years ago
I would like to volunteer a few hours a week on a group java project to gain real world experience. I am a beginner java programmer studying for my java certification.

Marcelo Gobelli
16 years ago