forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUtils.java
More file actions
29 lines (26 loc) · 814 Bytes
/
StringUtils.java
File metadata and controls
29 lines (26 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.examplehub.utils;
public class StringUtils {
public static String toString(char[] chars, int offset, int len) {
StringBuilder builder = new StringBuilder();
for (int i = offset; i < offset + len; ++i) {
builder.append(chars[i]);
}
return builder.toString();
}
public static String toString(byte[] bytes, int offset, int len) {
StringBuilder builder = new StringBuilder();
for (int i = offset; i < offset + len; ++i) {
builder.append(bytes[i]);
}
return builder.toString();
}
public static String capitalize(String origin) {
if (origin == null) {
throw new NullPointerException();
}
if (origin.length() == 0) {
return "";
}
return Character.toUpperCase(origin.charAt(0)) + origin.substring(1).toLowerCase();
}
}