Update TransitLock.java and UTFUtils.java
This commit is contained in:
parent
9950a4ceb1
commit
833c0f0c7c
@ -36,9 +36,11 @@ public class TransitLock {
|
||||
}
|
||||
|
||||
public void transit() {
|
||||
synchronized (synchronization) {
|
||||
startTransit();
|
||||
endTransit();
|
||||
}
|
||||
}
|
||||
|
||||
public void startTransit() {
|
||||
synchronized (synchronization) {
|
||||
|
@ -1,19 +1,21 @@
|
||||
package org.warp.commonutils.serialization;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class UTFUtils {
|
||||
public static final void writeUTF(DataOutputStream out, String utf) throws IOException {
|
||||
public static final void writeUTF(DataOutput out, String utf) throws IOException {
|
||||
byte[] bytes = utf.getBytes(StandardCharsets.UTF_8);
|
||||
out.writeInt(bytes.length);
|
||||
out.write(bytes);
|
||||
}
|
||||
|
||||
public static final String readUTF(DataInputStream in) throws IOException {
|
||||
public static final String readUTF(DataInput in) throws IOException {
|
||||
int len = in.readInt();
|
||||
return new String(in.readNBytes(len), StandardCharsets.UTF_8);
|
||||
byte[] data = new byte[len];
|
||||
in.readFully(data, 0, len);
|
||||
return new String(data, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user