List of usage examples for java.io BufferedReader close
public void close() throws IOException
From source file:com.amalto.workbench.utils.ResourcesUtil.java
public static void postResourcesFromFile(String typeName, String pathName, String uri) throws Exception { File file = new File(pathName); FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); postResourcesFromContentString(br.readLine(), uri, typeName); br.close(); fr.close();/*from www . ja va 2 s. c o m*/ }
From source file:br.org.acessobrasil.nucleuSilva.util.ObterPaginaLocal.java
/** * Mtodo que extrai o contedo de uma pgina. * @param url URL da pgina a ter seu contedo extrado. * @return Contedo de uma pgina./*w w w. j ava2 s. com*/ * @throws IOException Erro ao conectar a pgina. * @deprecated Utilize o mtodo getContent(). */ public static StringBuilder pegar(final URL url) throws IOException { //JOptionPane.showMessageDialog(null,"oi1"); StringBuilder buf = new StringBuilder(); File file = new File(nomeArquivoOuDiretorio); FileReader reader = new FileReader(file); BufferedReader leitor = new BufferedReader(reader); while (leitor.ready()) { buf.append(leitor.readLine() + "\n"); } leitor.close(); //JOptionPane.showMessageDialog(null,"oi2"); return buf; }
From source file:com.adito.activedirectory.ActiveDirectoryPropertyManager.java
private static void close(BufferedReader reader) { try {// w w w . j a v a 2 s. c o m if (reader != null) { reader.close(); } } catch (IOException e) { // ignore } }
From source file:com.tang.util.RequestBeanKit.java
/** * ?ajax????bean//from w w w . j a v a 2 s . c o m * @param request * @param valueType * @param <T> * @return */ public static <T> T getRequestObject(HttpServletRequest request, Class<T> valueType) { StringBuilder json = new StringBuilder(); try { BufferedReader reader = request.getReader(); String line = null; while ((line = reader.readLine()) != null) { json.append(line); } reader.close(); } catch (Exception e) { } System.out.println(json.toString()); return JSONObject.parseObject(json.toString(), valueType); }
From source file:Main.java
public static void readZipFile(String file) throws Exception { ZipFile zf = new ZipFile(file); InputStream in = new BufferedInputStream(new FileInputStream(file)); ZipInputStream zin = new ZipInputStream(in); ZipEntry ze;//from ww w . j av a2 s . c o m while ((ze = zin.getNextEntry()) != null) { if (ze.isDirectory()) { } else { System.err.println("file - " + ze.getName() + " : " + ze.getSize() + " bytes"); long size = ze.getSize(); if (size > 0) { BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } System.out.println(); } } zin.closeEntry(); }
From source file:Main.java
/** * Convert an {@link InputStream} to a String * * @param inputStream InputStream//from ww w. jav a2 s .c o m * @return String contents of the InputStream * @throws IOException */ private static String convertStreamToString(InputStream inputStream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } reader.close(); return sb.toString(); }
From source file:de.unijena.bioinf.ChemistryBase.chem.utils.PeriodicTableJSONReader.java
private static String readString(Reader reader) throws IOException { final StringBuilder buffer = new StringBuilder(); final BufferedReader bufReader = new BufferedReader(reader); try {// ww w.j a va 2 s . c o m while (bufReader.ready()) { buffer.append(bufReader.readLine()).append("\n"); } } finally { bufReader.close(); } return buffer.toString(); }
From source file:Main.java
public static String getFileOutputString(String path) { try {// w w w. ja v a 2 s .c om BufferedReader bufferedReader = new BufferedReader(new FileReader(path), 8192); StringBuilder sb = new StringBuilder(); String line = null; while ((line = bufferedReader.readLine()) != null) { sb.append("\n").append(line); } bufferedReader.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getSystemProperty(String propName) { String line = ""; BufferedReader input = null; try {/* w ww .j a va 2s . c o m*/ Process p = Runtime.getRuntime().exec("getprop " + propName); input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024); line = input.readLine(); input.close(); } catch (IOException ex) { Log.e(TAG, "Unable to read sysprop " + propName, ex); return null; } finally { if (input != null) { try { input.close(); } catch (IOException e) { Log.e(TAG, "Exception while closing InputStream", e); } } } return line; }
From source file:Main.java
/** * Converts a raw text file into a string. * * @param resId The resource ID of the raw text file about to be turned into a shader. * @return The context of the text file, or null in case of error. *//*from ww w . ja v a2s . c om*/ public static String readRawTextFile(Context con, int resId) { InputStream inputStream = con.getResources().openRawResource(resId); try { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } reader.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); } return null; }