MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / readString

Method readString

JSAT/src/jsat/io/JSATData.java:735–755  ·  view source on GitHub ↗
(DataInputStream in)

Source from the content-addressed store, hash-verified

733 }
734
735 private static String readString(DataInputStream in) throws IOException
736 {
737 StringBuilder builder = new StringBuilder();
738 byte encoding = in.readByte();
739 int bytesToRead = in.readInt();
740
741 switch(encoding)
742 {
743 case STRING_ENCODING_ASCII:
744 for (int i = 0; i < bytesToRead; i++)
745 builder.append(Character.toChars(in.readByte()));
746 return builder.toString();
747 case STRING_ENCODING_UTF_16:
748 byte[] bytes = new byte[bytesToRead];
749 in.readFully(bytes);
750 return new String(bytes, "UTF-16");
751 default:
752 throw new RuntimeException("Unkown string encoding value " + encoding);
753 }
754
755 }
756}

Callers 1

loadMethod · 0.95

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected