Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static int inputStreamToInt(InputStream inputStream) throws IOException { InputStream in = new BufferedInputStream(inputStream); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); try { String strValue = reader.readLine(); int intValue = Integer.parseInt(strValue); return intValue; } catch (IOException e) { throw e; } } }