Exemplo n.º 1
0
 public static String getLines(String s) {
   StringBuilder sb = new StringBuilder();
   int index = 0;
   for (int i = 1; index != -1; i++) {
     sb.append(i + "\n");
     index = s.indexOf("\n", index + 1);
   }
   return sb.toString();
 }
Exemplo n.º 2
0
 public static String inputStreamReaderToString(InputStreamReader in) throws Exception {
   StringBuilder sb = new StringBuilder();
   char[] buf = new char[1025];
   while (in.ready()) {
     sb.append((new String(buf, 0, in.read(buf, 0, 1024))).replaceAll("\r\n", "\n"));
   }
   in.close();
   String tmp = sb.toString();
   while (tmp.contains("\r\n")) {
     tmp = tmp.replaceAll("\r\n", "\n");
   }
   return tmp;
 }