mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Argh, god damn it, removed Java 1.6 methods again.
This commit is contained in:
@@ -21,7 +21,6 @@ import static org.briarproject.serial.Tag.TRUE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -235,7 +234,7 @@ class ReaderImpl implements Reader {
|
||||
if(length < 0 || length > maxLength) throw new FormatException();
|
||||
if(length == 0) return "";
|
||||
readIntoBuffer(length, true);
|
||||
return new String(buf, 0, length, Charset.forName("UTF-8"));
|
||||
return new String(buf, 0, length, "UTF-8");
|
||||
}
|
||||
|
||||
private int readStringLength(boolean consume) throws IOException {
|
||||
|
||||
@@ -16,7 +16,6 @@ import static org.briarproject.serial.Tag.TRUE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -103,7 +102,7 @@ class WriterImpl implements Writer {
|
||||
}
|
||||
|
||||
public void writeString(String s) throws IOException {
|
||||
byte[] b = s.getBytes(Charset.forName("UTF-8"));
|
||||
byte[] b = s.getBytes("UTF-8");
|
||||
if(b.length <= Byte.MAX_VALUE) {
|
||||
write(STRING_8);
|
||||
write((byte) b.length);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.util;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
@@ -14,11 +14,19 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
public static byte[] toUtf8(String s) {
|
||||
return s.getBytes(Charset.forName("UTF-8"));
|
||||
try {
|
||||
return s.getBytes("UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String fromUtf8(byte[] bytes) {
|
||||
return new String(bytes, Charset.forName("UTF-8"));
|
||||
try {
|
||||
return new String(bytes, "UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Converts the given byte array to a hex character array. */
|
||||
|
||||
Reference in New Issue
Block a user