Guest User

Untitled

a guest
Jan 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. public String ReadUtf8String(DataInputStream stream) {
  2. try {
  3. ArrayList<Byte> bytes = new ArrayList<Byte>();
  4. byte curByte;
  5. while ((curByte = stream.readByte()) != 0) {
  6. bytes.add(curByte);
  7. }
  8.  
  9. Byte as_Byte[] = (Byte[]) bytes.toArray();
  10. byte as_byte[] = new byte[as_Byte.length];
  11. for (int i = 0; i<as_Byte.length; i++) {
  12. as_byte[i] = as_Byte[i].byteValue();
  13. }
  14. return new String(as_byte, "UTF-8");
  15. } catch (IOException ex) {
  16.  
  17. }
  18. return null;
  19. }
Add Comment
Please, Sign In to add comment