Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/networkTools.java
| Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | static String parseStreamToString(InputStream is) throws IOException{ | ||||
| while( rsz >0) { | while( rsz >0) { | ||||
| out.append(buffer, 0, rsz); | out.append(buffer, 0, rsz); | ||||
| rsz = in.read(buffer, 0, buffer.length); | rsz = in.read(buffer, 0, buffer.length); | ||||
| } | } | ||||
| return out.toString(); | return out.toString(); | ||||
| } | } | ||||
| /** | |||||
| * Parses string into int, return 0 if it fails | |||||
| * @param str the string to parse | |||||
| * @return the value as int, 0 if it fails | |||||
| */ | |||||
| static int failsafeParseInt(String str) { | static int failsafeParseInt(String str) { | ||||
| try { | try { | ||||
| return Integer.parseInt(str); | return Integer.parseInt(str); | ||||
| } catch(NumberFormatException e) { | } catch(NumberFormatException e) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register