Advertisement
iPeer

Untitled

May 12th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. package com.ipeer.minecraft.servers;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.IOException;
  5.  
  6. public class Packet {
  7.  
  8.     public static String readLine(DataInputStream in, int maxLen) throws IOException {
  9.         StringBuilder stringbuilder = new StringBuilder();
  10.         short word = in.readShort();
  11.        
  12.         if (word > maxLen)
  13.             throw new IOException("THE STRING IS TOO LONG!");
  14.        
  15.         if (word < 0)
  16.             throw new IOException("What...? The string has a length < 0!");
  17.        
  18.         for (int i = 0; i < word; i++)
  19.         {
  20.             stringbuilder.append(in.readChar());
  21.         }
  22.  
  23.         return stringbuilder.toString();
  24.     }
  25.    
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement