List of usage examples for java.io InputStreamReader InputStreamReader
public InputStreamReader(InputStream in)
From source file:Main.java
public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line;//w w w .j a v a 2s . c om while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } return sb.toString(); }
From source file:Main.java
public static String getContent(String fileName) { try {/* www . java 2 s .c o m*/ InputStreamReader inputReader = new InputStreamReader(new FileInputStream(fileName)); BufferedReader bufReader = new BufferedReader(inputReader); String line = ""; String Result = ""; while ((line = bufReader.readLine()) != null) Result += line; //System.out.print(Result); return Result; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null;/*from w ww . j a v a2 s . c o m*/ while ((line = reader.readLine()) != null) { sb.append(line); } is.close(); return sb.toString(); }
From source file:Main.java
public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null;//from w ww . j av a 2 s .com String NL = System.getProperty("line.separator"); while ((line = reader.readLine()) != null) { sb.append(line + NL); } sb.replace(sb.length() - 1, sb.length(), ""); is.close(); return sb.toString(); }
From source file:Main.java
public static String getContent(Context context, String fileName) { try {//from w w w .j a v a 2 s . co m InputStreamReader inputReader = new InputStreamReader( context.getResources().getAssets().open(fileName)); BufferedReader bufReader = new BufferedReader(inputReader); String line = ""; String Result = ""; while ((line = bufReader.readLine()) != null) Result += line; System.out.print(Result); return Result; } catch (Exception e) { e.printStackTrace(); return null; } }