Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/ru/greycat/algorithms/strip/Kevin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ru.greycat.algorithms.strip;

public class Kevin implements StripAlgorithm {
private char[] chars = new char[256];

public Kevin() {
}

@Override
public String strip(String s) throws Exception {
final int length = s.length();
if (length > chars.length) {
chars = new char[length];
}
int newLen = 0;
for (int j = 0; j < length; j++) {
final char ch = s.charAt(j);
if (ch >= ' ') {
chars[newLen] = ch;
newLen++;
}
}
if (newLen != length) {
return new String(chars, 0, newLen);
}
return s;
}
}