Open Kilda Java Documentation
IoUtil.java
Go to the documentation of this file.
1 package org.openkilda.utility;
2 
3 import java.io.BufferedReader;
4 import java.io.Closeable;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.InputStreamReader;
8 import java.util.function.Predicate;
9 
13 public final class IoUtil {
14 
18  private IoUtil() {
19 
20  }
21 
29  public static String toString(final InputStream inputStream) throws IOException {
30  StringBuilder data = new StringBuilder();
31  try(BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream))) {
32  String line = null;
33  while ((line = rd.readLine()) != null) {
34  if (!line.isEmpty()) {
35  data.append(line);
36  }
37  }
38  }
39  return data.toString();
40  }
41 
47  public static void close(final Closeable closeable) {
48  if (closeable != null) {
49  try {
50  closeable.close();
51  } catch (Exception e) {
52  // Do Nothing
53  }
54  }
55  }
56 
57 
64  public static boolean chkStringIsNotEmpty(String value) {
65  if(value != null){
66  Predicate<String> predicates = s->{return value.trim().length()>0;};
67  return predicates.test(value);
68  }
69  return false;
70  }
71 }
value
Definition: nodes.py:62
static boolean chkStringIsNotEmpty(String value)
Definition: IoUtil.java:64
static String toString(final InputStream inputStream)
Definition: IoUtil.java:29
static void close(final Closeable closeable)
Definition: IoUtil.java:47