MCPcopy Create free account
hub / github.com/Frontrooms/3.0-GC / readFromInputStream

Method readFromInputStream

src/main/java/emu/grasscutter/utils/Utils.java:252–265  ·  view source on GitHub ↗

Retrieves a string from an input stream. @param stream The input stream. @return The string.

(@Nullable InputStream stream)

Source from the content-addressed store, hash-verified

250 * @return The string.
251 */
252 public static String readFromInputStream(@Nullable InputStream stream) {
253 if(stream == null) return "empty";
254
255 StringBuilder stringBuilder = new StringBuilder();
256 try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
257 String line; while ((line = reader.readLine()) != null) {
258 stringBuilder.append(line);
259 } stream.close();
260 } catch (IOException e) {
261 Grasscutter.getLogger().warn("Failed to read from input stream.");
262 } catch (NullPointerException ignored) {
263 return "empty";
264 } return stringBuilder.toString();
265 }
266
267 /**
268 * Performs a linear interpolation using a table of fixed points to create an effective piecewise f(x) = y function.

Callers 1

LanguageMethod · 0.95

Calls 4

getLoggerMethod · 0.95
closeMethod · 0.65
appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected