summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.lfs')
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java10
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/InvalidLongObjectIdException.java9
2 files changed, 9 insertions, 10 deletions
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
index 0f62025be5..56e7987443 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
@@ -42,6 +42,8 @@
*/
package org.eclipse.jgit.lfs;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -49,7 +51,6 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
-import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Locale;
@@ -120,7 +121,7 @@ public class LfsPointer {
*/
public void encode(OutputStream out) {
try (PrintStream ps = new PrintStream(out, false,
- StandardCharsets.UTF_8.name())) {
+ UTF_8.name())) {
ps.print("version "); //$NON-NLS-1$
ps.print(VERSION + "\n"); //$NON-NLS-1$
ps.print("oid " + HASH_FUNCTION_NAME + ":"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -129,8 +130,7 @@ public class LfsPointer {
ps.print(size + "\n"); //$NON-NLS-1$
} catch (UnsupportedEncodingException e) {
// should not happen, we are using a standard charset
- throw new UnsupportedCharsetException(
- StandardCharsets.UTF_8.name());
+ throw new UnsupportedCharsetException(UTF_8.name());
}
}
@@ -152,7 +152,7 @@ public class LfsPointer {
long sz = -1;
try (BufferedReader br = new BufferedReader(
- new InputStreamReader(in, StandardCharsets.UTF_8.name()))) {
+ new InputStreamReader(in, UTF_8))) {
for (String s = br.readLine(); s != null; s = br.readLine()) {
if (s.startsWith("#") || s.length() == 0) { //$NON-NLS-1$
continue;
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/InvalidLongObjectIdException.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/InvalidLongObjectIdException.java
index 44ac317a16..ee33d905dc 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/InvalidLongObjectIdException.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/InvalidLongObjectIdException.java
@@ -45,7 +45,8 @@
package org.eclipse.jgit.lfs.errors;
-import java.io.UnsupportedEncodingException;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
import java.text.MessageFormat;
import org.eclipse.jgit.lfs.internal.LfsText;
@@ -80,10 +81,8 @@ public class InvalidLongObjectIdException extends IllegalArgumentException {
private static String asAscii(byte[] bytes, int offset, int length) {
try {
- return new String(bytes, offset, length, "US-ASCII"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e2) {
- return ""; //$NON-NLS-1$
- } catch (StringIndexOutOfBoundsException e2) {
+ return new String(bytes, offset, length, US_ASCII);
+ } catch (StringIndexOutOfBoundsException e) {
return ""; //$NON-NLS-1$
}
}