This commit is contained in:
tanghc
2019-02-27 21:10:46 +08:00
parent 46a546f1da
commit 5b32524a83
17 changed files with 89 additions and 31 deletions

View File

@@ -101,30 +101,35 @@ public class StreamUtil {
this.lock = lock;
}
@Override
public void write(int datum) throws IOException {
synchronized (lock) {
out.write(datum);
}
}
@Override
public void write(byte[] data) throws IOException {
synchronized (lock) {
out.write(data);
}
}
@Override
public void write(byte[] data, int offset, int length) throws IOException {
synchronized (lock) {
out.write(data, offset, length);
}
}
@Override
public void flush() throws IOException {
synchronized (lock) {
out.flush();
}
}
@Override
public void close() throws IOException {
synchronized (lock) {
out.close();

View File

@@ -44,12 +44,14 @@ public abstract class StringUtils {
}
char[] chars = obj.toString().toCharArray();
int length = chars.length;
if(length < 1)
return false;
if(length < 1) {
return false;
}
int i = 0;
if(length > 1 && chars[0] == '-')
i = 1;
if(length > 1 && chars[0] == '-') {
i = 1;
}
for (; i < length; i++) {
if (!Character.isDigit(chars[i])) {
@@ -91,8 +93,9 @@ public abstract class StringUtils {
* 过滤不可见字符
*/
public static String stripNonValidXMLCharacters(String input) {
if (input == null || ("".equals(input)))
return "";
if (input == null || ("".equals(input))) {
return "";
}
StringBuilder out = new StringBuilder();
char current;
for (int i = 0; i < input.length(); i++) {
@@ -100,8 +103,9 @@ public abstract class StringUtils {
if ((current == 0x9) || (current == 0xA) || (current == 0xD)
|| ((current >= 0x20) && (current <= 0xD7FF))
|| ((current >= 0xE000) && (current <= 0xFFFD))
|| ((current >= 0x10000) && (current <= 0x10FFFF)))
out.append(current);
|| ((current >= 0x10000) && (current <= 0x10FFFF))) {
out.append(current);
}
}
return out.toString();
}