-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df46c9c
commit 0633409
Showing
6 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package me.fallenbreath.yamlang.utils; | ||
|
||
import java.io.IOException; | ||
import java.io.Reader; | ||
|
||
public class IOUtils | ||
{ | ||
public static String readerToString(Reader reader) throws IOException | ||
{ | ||
StringBuilder builder = new StringBuilder(); | ||
char[] buf = new char[4096]; | ||
int n; | ||
while ((n = reader.read(buf)) != -1) | ||
{ | ||
builder.append(buf, 0, n); | ||
} | ||
return builder.toString(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/fallenbreath/yamlang/utils/StringUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.fallenbreath.yamlang.utils; | ||
|
||
public class StringUtils | ||
{ | ||
/** | ||
* No need to handle those codepoint things, | ||
* cuz this method is only used to capitalize a gradle source set name | ||
*/ | ||
public static String capitalize(final String str) | ||
{ | ||
if (str == null || str.isEmpty()) | ||
{ | ||
return str; | ||
} | ||
|
||
char firstChar = str.charAt(0); | ||
if (firstChar > 0x7F /* unicode? */ || Character.isUpperCase(firstChar)) | ||
{ | ||
return str; | ||
} | ||
else | ||
{ | ||
return Character.toUpperCase(firstChar) + str.substring(1); | ||
} | ||
} | ||
} |