Java Code Examples for java.io.BufferedReader
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project Amantech, under directory /Android/CloudAppStudioAndroid/src/com/cloudappstudio/utility/.
Source file: CloudOAuth.java

private String readTextFromHttpResponse(HttpResponse response) throws IllegalStateException, IOException { BufferedReader reader=new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb=new StringBuffer(); String line; while ((line=reader.readLine()) != null) { sb.append(line); } reader.close(); return sb.toString(); }
Example 2
From project aether-core, under directory /aether-test-util/src/main/java/org/eclipse/aether/internal/test/util/.
Source file: DependencyGraphParser.java

/** * Parse the given graph definition. */ public DependencyNode parseLiteral(String dependencyGraph) throws IOException { BufferedReader reader=new BufferedReader(new StringReader(dependencyGraph)); DependencyNode node=parse(reader); reader.close(); return node; }
Example 3
From project amber, under directory /oauth-2.0/test-utils/src/main/java/org/apache/amber/oauth2/utils/test/.
Source file: FileUtils.java

public static String readTextFileAsString(String fileName) throws IOException { URL inputStream=ClassLoader.getSystemResource(fileName); BufferedReader br=new BufferedReader(new InputStreamReader(inputStream.openStream())); String line; StringBuffer buffer=new StringBuffer(); while ((line=br.readLine()) != null) { buffer.append(line); } return buffer.toString(); }
Example 4
From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Threads/.
Source file: CheckTicketThread.java

private void loadCheckTickets(File dataFolder){ checkedTicketsFile=new File(dataFolder,"usedTickets.txt"); if (!checkedTicketsFile.exists()) return; try { BufferedReader bReader=new BufferedReader(new FileReader(checkedTicketsFile)); String line=""; while ((line=bReader.readLine()) != null) if (!line.isEmpty()) checkedTickets.add(Integer.valueOf(line)); bReader.close(); } catch ( Exception e) { ConsoleUtils.printException(e,Core.NAME,"Can't load used ticket names!"); } }
Example 5
From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generator/model/.
Source file: Model.java

public boolean loadModel(String file) throws IOException { File f=new File(file); if (f.exists()) { relations.clear(); BufferedReader r=new BufferedReader(new FileReader(f)); readFromStream(r); r.close(); return true; } else { System.err.println("File not found: " + file); return false; } }
Example 6
From project ACLS-protocol-library, under directory /aclslib/src/main/java/au/edu/uq/cmm/aclslib/message/.
Source file: ResponseReaderImpl.java

public Response read(InputStream source) throws AclsException { BufferedReader br=new BufferedReader(new InputStreamReader(source)); try { return readResponse(createLineScanner(br)); } catch ( IOException ex) { throw new AclsCommsException("IO error while reading response",ex); } }
Example 7
From project addis, under directory /application/src/main/java/org/drugis/addis/util/.
Source file: AtcParser.java

public List<AtcDescription> parse(InputStream is) throws IOException { String inputLine; List<AtcDescription> finalList=new ArrayList<AtcDescription>(); BufferedReader readCode=new BufferedReader(new InputStreamReader(is)); while ((inputLine=readCode.readLine()) != null) { if (!findDrugDetails(inputLine).isEmpty()) { finalList.addAll(findDrugDetails(inputLine)); } } return finalList; }
Example 8
private static void printOutput(Process p) throws IOException { BufferedReader input=new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line=input.readLine()) != null) { System.out.println(line); System.out.flush(); } input.close(); }
Example 9
From project AlarmApp-Android, under directory /src/org/alarmapp/web/http/.
Source file: HttpUtil.java

private static String read(InputStream stream) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(stream)); StringBuilder stringBuilder=new StringBuilder(); String line=null; while ((line=br.readLine()) != null) { stringBuilder.append(line); } return stringBuilder.toString(); }
Example 10
From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/statement/.
Source file: MakeStatementActivity.java

private String makeStringFromEntity(HttpEntity responseEntity) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(responseEntity.getContent(),"utf-8")); StringBuilder builder=new StringBuilder(); String line; while ((line=br.readLine()) != null) { Log.d(TAG,"makeStringFromEntity | " + line); if ("<!DOCTYPE html>".equals(line)) { Log.e(TAG,"Received HTML!"); return "{\"error\": \"Server error\"}"; } builder.append(line); } return builder.toString(); }
Example 11
From project anadix, under directory /anadix-tests/src/main/java/org/anadix/test/.
Source file: SourceTestTemplate.java

/** * Reads the whole reader and returns the text in it * @param r Reader to read * @return text in reader */ protected static String readReader(Reader r){ try { BufferedReader br=new BufferedReader(r); StringBuilder sb=new StringBuilder(); String line; while ((line=br.readLine()) != null) { sb.append(line).append("\n"); } return sb.toString(); } catch ( IOException ex) { throw new RuntimeException(ex); } }
Example 12
From project android-api_1, under directory /android-lib/src/com/catchnotes/api/.
Source file: CatchAPI.java

private static String istreamToString(InputStream inputStream) throws IOException { StringBuilder outputBuilder=new StringBuilder(); String string; if (inputStream != null) { BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream,ENCODING)); while (null != (string=reader.readLine())) { outputBuilder.append(string).append('\n'); } reader.close(); } return outputBuilder.toString(); }
Example 13
From project android-joedayz, under directory /Proyectos/FBConnectTest/src/com/facebook/android/.
Source file: Util.java

private static String read(InputStream in) throws IOException { StringBuilder sb=new StringBuilder(); BufferedReader r=new BufferedReader(new InputStreamReader(in),1000); for (String line=r.readLine(); line != null; line=r.readLine()) { sb.append(line); } in.close(); return sb.toString(); }
Example 14
From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/facebook/extpack/com/facebook/android/.
Source file: Util.java

private static String read(InputStream in) throws IOException { StringBuilder sb=new StringBuilder(); BufferedReader r=new BufferedReader(new InputStreamReader(in),1000); for (String line=r.readLine(); line != null; line=r.readLine()) { sb.append(line); } in.close(); return sb.toString(); }
Example 15
From project android-tether, under directory /facebook/src/com/facebook/android/.
Source file: Util.java

private static String read(InputStream in) throws IOException { StringBuilder sb=new StringBuilder(); BufferedReader r=new BufferedReader(new InputStreamReader(in),1000); for (String line=r.readLine(); line != null; line=r.readLine()) { sb.append(line); } in.close(); return sb.toString(); }
Example 16
From project AndroidCommon, under directory /src/com/asksven/android/common/kernelutils/.
Source file: Wakelocks.java

private static ArrayList<String[]> parseDelimitedFile(String filePath,String delimiter){ ArrayList<String[]> rows=new ArrayList<String[]>(); try { FileReader fr=new FileReader(filePath); BufferedReader br=new BufferedReader(fr); String currentRecord; while ((currentRecord=br.readLine()) != null) rows.add(currentRecord.split(delimiter)); br.close(); } catch ( Exception e) { } return rows; }
Example 17
/** * Reads the password from stdin and returns it as a string. * @param keyFile The file containing the private key. Used to prompt the user. */ private static String readPassword(File keyFile){ System.out.print("Enter password for " + keyFile + " (password will not be hidden): "); System.out.flush(); BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); try { return stdin.readLine(); } catch ( IOException ex) { return null; } }
Example 18
From project android_packages_apps_Exchange, under directory /tests/src/com/android/exchange/utility/.
Source file: CalendarUtilitiesTests.java

private BlockHash parseIcsContent(byte[] bytes) throws IOException { BufferedReader reader=new BufferedReader(new StringReader(Utility.fromUtf8(bytes))); String line=reader.readLine(); if (!line.equals("BEGIN:VCALENDAR")) { throw new IllegalArgumentException(); } return new BlockHash("VCALENDAR",reader); }
Example 19
From project androlog, under directory /androlog/src/main/java/de/akquinet/android/androlog/reporter/.
Source file: PostReporter.java

/** * Reads an input stream and returns the result as a String. * @param in the input stream * @return the read String * @throws IOException if the stream cannot be read. */ public static String read(InputStream in) throws IOException { InputStreamReader isReader=new InputStreamReader(in,"UTF-8"); BufferedReader reader=new BufferedReader(isReader); StringBuffer out=new StringBuffer(); char[] c=new char[4096]; for (int n; (n=reader.read(c)) != -1; ) { out.append(new String(c,0,n)); } reader.close(); return out.toString(); }
Example 20
From project ant4eclipse, under directory /org.ant4eclipse.lib.jdt/src/org/ant4eclipse/lib/jdt/internal/model/jre/.
Source file: JavaExecuter.java

/** * <p> Returns </p> * @param inputstream * @return * @throws IOException */ private String[] extractFromInputStream(InputStream inputstream) throws IOException { InputStreamReader inputstreamreader=new InputStreamReader(inputstream); BufferedReader bufferedreader=new BufferedReader(inputstreamreader); List<String> sysOut=new LinkedList<String>(); String line; while ((line=bufferedreader.readLine()) != null) { sysOut.add(line); } return sysOut.toArray(new String[0]); }
Example 21
From project any23, under directory /core/src/main/java/org/apache/any23/util/.
Source file: StreamUtils.java

/** * Returns all the lines read from an input stream. * @param is input stream. * @return list of not <code>null</code> lines. * @throws IOException */ public static String[] asLines(InputStream is) throws IOException { final BufferedReader br=new BufferedReader(new InputStreamReader(is)); final List<String> lines=new ArrayList<String>(); try { String line; while ((line=br.readLine()) != null) { lines.add(line); } return lines.toArray(new String[lines.size()]); } finally { closeGracefully(br); } }
Example 22
From project apb, under directory /modules/apb-base/src/apb/testrunner/output/.
Source file: JUnitTestReport.java

private static void copyFile(File file,PrintStream out) throws IOException { BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(file),UTF8)); String line; while ((line=reader.readLine()) != null) { if (!line.startsWith(XML_HEADER_START)) { out.println(" " + line); } } reader.close(); }
Example 23
From project Apertiurm-Androind-app-devlopment, under directory /ApertiumAndroid/src/org/apertium/android/Internet/.
Source file: InternetManifest.java

public InternetManifest(String ManifestFile) throws IOException { manifestRowList=new ArrayList<ManifestRow>(); InputStream is=new FileInputStream(AppPreference.TEMP_DIR + "/" + AppPreference.MANIFEST_FILE); BufferedReader reader=new BufferedReader(new InputStreamReader(is)); String input=""; if (is != null) { while ((input=reader.readLine()) != null) { String[] Row=input.split("\t"); if (Row.length > 2) { manifestRowList.add(new ManifestRow(Row[0],Row[1],Row[2],Row[3])); } } } }
Example 24
From project archive-commons, under directory /archive-commons/src/main/java/org/archive/url/.
Source file: SURT.java

public static void main(String[] args){ String line; InputStreamReader isr=new InputStreamReader(System.in,Charset.forName("UTF-8")); BufferedReader br=new BufferedReader(isr); Iterator<String> i=AbstractPeekableIterator.wrapReader(br); while (i.hasNext()) { line=i.next(); System.out.println(toSURT(line)); } }
Example 25
From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial/src/org/eclipse/acceleo/tutorial/wizard/.
Source file: EclipseConWizard.java

/** * Tries and find an encoding value on the very first line of the file contents. * @param fileContent The content from which to read an encoding value. * @return The charset name if it exists and is supported, <code>null</code> otherwise */ private static String getCharset(String fileContent){ String trimmedContent=fileContent.trim(); String charsetName=null; if (trimmedContent.length() > 0) { BufferedReader reader=new BufferedReader(new StringReader(trimmedContent)); String firstLine=trimmedContent; try { firstLine=reader.readLine(); } catch ( IOException e) { } Pattern encodingPattern=Pattern.compile("encoding\\s*=\\s*(\"|\')?([-a-zA-Z0-9]+)\1?"); Matcher matcher=encodingPattern.matcher(firstLine); if (matcher.find()) { charsetName=matcher.group(2); } } if (charsetName != null && Charset.isSupported(charsetName)) { return charsetName; } return null; }
Example 26
From project AceWiki, under directory /src/ch/uzh/ifi/attempto/aceeditor/.
Source file: LexiconHandler.java

/** * Creates a new lexicon handler object and loads the given lexicon file. * @param lexiconFile The lexicon file to be loaded. */ public LexiconHandler(String lexiconFile){ if (lexiconFile == null || lexiconFile.equals("")) { return; } try { BufferedReader in=new BufferedReader(new FileReader(lexiconFile)); String line=in.readLine(); while (line != null) { addWord(line); line=in.readLine(); } in.close(); } catch ( Exception ex) { ex.printStackTrace(); } }
Example 27
From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/service/alfresco/.
Source file: AlfrescoKickstartServiceImpl.java

public String getWorkflowMetaData(String processDefinitionId,String metadataKey){ String metadataFile=processDefinitionId; if (metadataKey.equals(MetaDataKeys.WORKFLOW_JSON_SOURCE)) { metadataFile=metadataFile + ".json"; } Document document=getDocumentFromFolder(WORKFLOW_DEFINITION_FOLDER,metadataFile); StringBuilder strb=new StringBuilder(); BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(document.getContentStream().getStream())); try { String line=bufferedReader.readLine(); while (line != null) { strb.append(line); line=bufferedReader.readLine(); } } catch ( Exception e) { LOGGER.log(Level.SEVERE,"Could not read metadata '" + metadataKey + "' : "+ e.getMessage()); e.printStackTrace(); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch ( IOException e) { e.printStackTrace(); } } } return strb.toString(); }
Example 28
From project AdminCmd, under directory /src/main/java/be/Balor/Manager/Terminal/Commands/.
Source file: UnixTerminalCommand.java

@Override public void execute(final CommandSender sender){ try { ProcessBuilder pb; if (args != null) { pb=new ProcessBuilder(execution,args); } else { pb=new ProcessBuilder(execution); } pb.redirectErrorStream(true); pb.directory(workingDir); final Process p=pb.start(); final BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream())); String line=null; while ((line=in.readLine()) != null) { sender.sendMessage(line); } } catch ( final Throwable e) { sender.sendMessage("CMD ERROR : " + e.getMessage()); e.printStackTrace(); } }
Example 29
From project AdServing, under directory /modules/services/geo/src/main/java/net/mad/ads/services/geo/lucene/.
Source file: GeoIpIndex.java

private Map<String,Map<String,String>> getLocations(String path) throws IOException { if (!path.endsWith("/")) { path+="/"; } String filename=path + "GeoLiteCity-Location.csv"; Map<String,Map<String,String>> result=new HashMap<String,Map<String,String>>(); BufferedReader br=new BufferedReader(new FileReader(filename)); CSVReader reader=new CSVReader(br,',','\"',2); String[] values; while ((values=reader.readNext()) != null) { Map<String,String> loc=new HashMap<String,String>(); loc.put("locid",values[0]); loc.put("country",values[1]); loc.put("region",values[2]); loc.put("city",values[3]); loc.put("postalcode",values[4]); loc.put("latitude",values[5]); loc.put("longitude",values[6]); result.put(values[0],loc); } return result; }
Example 30
From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/discovery/.
Source file: NDKDiscoveredPathInfo.java

private void load(){ try { File infoFile=getInfoFile(); if (!infoFile.exists()) return; long timestamp=IFile.NULL_STAMP; List<IPath> includes=new ArrayList<IPath>(); Map<String,String> defines=new HashMap<String,String>(); BufferedReader reader=new BufferedReader(new FileReader(infoFile)); for (String line=reader.readLine(); line != null; line=reader.readLine()) { switch (line.charAt(0)) { case 't': timestamp=Long.valueOf(line.substring(2)); break; case 'i': includes.add(Path.fromPortableString(line.substring(2))); break; case 'd': int n=line.indexOf(',',2); if (n == -1) defines.put(line.substring(2),""); else defines.put(line.substring(2,n),line.substring(n + 1)); break; } } reader.close(); lastUpdate=timestamp; includePaths=includes.toArray(new IPath[includes.size()]); symbols=defines; } catch (IOException e) { Activator.log(e); } }
Example 31
From project adt-maven-plugin, under directory /src/main/java/com/yelbota/plugins/adt/utils/.
Source file: CleanStream.java

public void run(){ try { InputStreamReader isr=new InputStreamReader(is); BufferedReader br=new BufferedReader(isr); String line=null; while ((line=br.readLine()) != null) { if (log != null) { if (type == null) { log.info(line); } else { if (type == CleanStreamType.INFO) { log.info(line); } else if (type == CleanStreamType.DEBUG) { log.debug(line); } else if (type == CleanStreamType.ERROR) { log.error(line); } } } } } catch ( IOException ioe) { ioe.printStackTrace(); } }
Example 32
From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageData/.
Source file: ViewTools.java

public String getCommitUrl() throws IOException, CantDoThatException { String commitFileName=this.request.getSession().getServletContext().getRealPath("/lastcommit.txt"); File commitFile=new File(commitFileName); try { InputStream inputStream=new FileInputStream(commitFileName); BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream,Charset.forName("UTF-8"))); String commitLine=reader.readLine(); String commitId=commitLine.replace("commit ",""); inputStream.close(); return "https://github.com/okohll/agileBase/commit/" + commitId; } catch ( FileNotFoundException fnfex) { logger.error("Commit file " + commitFileName + " not found: "+ fnfex); throw new CantDoThatException("Commit log not found"); } }
Example 33
From project aim3-tu-berlin, under directory /seminar/exercises/datamining/core/src/test/java/de/tuberlin/dima/aim/exercises/.
Source file: HadoopAndPactTestcase.java

public List<String> readLines(String path) throws IOException { List<String> lines=new ArrayList<String>(); BufferedReader reader=null; try { reader=new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(path))); String line; while ((line=reader.readLine()) != null) { lines.add(line); } } finally { IOUtils.quietClose(reader); } return lines; }
Example 34
From project airlift, under directory /bootstrap/src/main/java/io/airlift/bootstrap/.
Source file: LoggingWriter.java

@Override public void flush(){ BufferedReader in=new BufferedReader(new StringReader(getBuffer().toString())); for (; ; ) { try { String line=in.readLine(); if (line == null) { break; } switch (type) { default : case DEBUG: { if (logger.isDebugEnabled()) { logger.debug(line); } break; } case INFO: { if (logger.isInfoEnabled()) { logger.info(line); } break; } } } catch (IOException e) { throw new Error(e); } } getBuffer().setLength(0); }
Example 35
From project Airports, under directory /src/com/nadmm/airports/notams/.
Source file: NotamFragmentBase.java

private HashMap<String,ArrayList<String>> parseNotams(File notamFile){ HashMap<String,ArrayList<String>> notams=new HashMap<String,ArrayList<String>>(); BufferedReader in=null; try { Set<String> notamIDs=new HashSet<String>(); in=new BufferedReader(new FileReader(notamFile)); String notam; while ((notam=in.readLine()) != null) { String parts[]=notam.split(" ",5); String notamID=parts[1]; if (!notamIDs.contains(notamID)) { String keyword=parts[0].equals("!FDC") ? "FDC" : parts[3]; String subject=DataUtils.getNotamSubjectFromKeyword(keyword); ArrayList<String> list=notams.get(subject); if (list == null) { list=new ArrayList<String>(); } list.add(notam); notams.put(subject,list); notamIDs.add(notamID); } } } catch ( IOException e) { } finally { try { if (in != null) { in.close(); } } catch ( IOException e) { } } return notams; }
Example 36
From project ajah, under directory /ajah-util/src/main/java/com/ajah/util/io/file/.
Source file: FileUtils.java

/** * Reads a file and returns the lines of it as a list of strings. Handles opening a closing the file. If there are any errors other than that the file does not exist, will return an empty or partial list. Will ignore any line that starts with "#". * @param fileName The name of the file to load, required. * @return List of lines in the file. * @throws FileNotFoundException If the file does not exist. */ public static List<String> readFileAsLines(final String fileName) throws FileNotFoundException { if (fileName == null || fileName.length() < 1) { throw new IllegalArgumentException("Filename may not be null or empty"); } final File file=new File(fileName); if (!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); } final List<String> data=new ArrayList<>(); BufferedReader in=null; try { in=new BufferedReader(new FileReader(file)); while (in.ready()) { final String line=in.readLine(); if (line != null && !line.startsWith("#") && line.length() > 0) { data.add(line); } } } catch ( final IOException e) { log.log(Level.SEVERE,e.getMessage(),e); } finally { if (in != null) { try { in.close(); } catch ( final IOException e) { log.log(Level.SEVERE,e.getMessage(),e); } } } log.log(Level.FINER,data.size() + " elements loaded."); return data; }
Example 37
/** * Load a list of paths from a file * @param fs * @param inputPath * @return * @throws IOException */ public static List<Path> loadPaths(FileSystem fs,Path inputPath) throws IOException { List<Path> retPaths=new ArrayList<Path>(); BufferedReader reader=null; try { reader=new BufferedReader(new InputStreamReader(fs.open(inputPath))); String line=null; while ((line=reader.readLine()) != null) { retPaths.add(new Path(line)); } } catch ( IOException e) { LOG.error("Exception in loadPaths for inputPath: " + inputPath.toString()); } finally { checkAndClose(reader); } return retPaths; }
Example 38
From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/webservice/.
Source file: AVService.java

private String convertStreamToString(final InputStream is) throws AVServiceErrorException { final StringBuilder sb=new StringBuilder(); try { final BufferedReader reader=new BufferedReader(new InputStreamReader(is,"UTF-8")); String line=null; while ((line=reader.readLine()) != null) { sb.append(line + '\n'); } } catch ( final IOException e) { throw new AVServiceErrorException(999); } finally { try { is.close(); } catch ( final IOException e) { throw new AVServiceErrorException(999); } } return sb.toString(); }
Example 39
From project alfredo, under directory /alfredo/src/test/java/com/cloudera/alfredo/client/.
Source file: AuthenticatorTestCase.java

protected void _testAuthentication(Authenticator authenticator,boolean doPost) throws Exception { start(); try { URL url=new URL(getBaseURL()); AuthenticatedURL.Token token=new AuthenticatedURL.Token(); AuthenticatedURL aUrl=new AuthenticatedURL(authenticator); HttpURLConnection conn=aUrl.openConnection(url,token); String tokenStr=token.toString(); if (doPost) { conn.setRequestMethod("POST"); conn.setDoOutput(true); } conn.connect(); if (doPost) { Writer writer=new OutputStreamWriter(conn.getOutputStream()); writer.write(POST); writer.close(); } assertEquals(HttpURLConnection.HTTP_OK,conn.getResponseCode()); if (doPost) { BufferedReader reader=new BufferedReader(new InputStreamReader(conn.getInputStream())); String echo=reader.readLine(); assertEquals(POST,echo); assertNull(reader.readLine()); } aUrl=new AuthenticatedURL(); conn=aUrl.openConnection(url,token); conn.connect(); assertEquals(HttpURLConnection.HTTP_OK,conn.getResponseCode()); assertEquals(tokenStr,token.toString()); } finally { stop(); } }
Example 40
From project ALP, under directory /workspace/alp-utils/src/main/java/com/lohika/alp/utils/object/reader/.
Source file: ReadXMLObject.java

/** * Unmarshal the object. * @param XML file * @return the Object * @throws IOException Signals that an I/O exception has occurred. */ public Object getObject(String XMLfile) throws IOException { URL url=this.getClass().getClassLoader().getResource(XMLfile); File file; if (url == null) file=new File(XMLfile); else file=new File(url.getPath()); if (file.exists()) { char[] buffer=null; BufferedReader bufferedReader=new BufferedReader(new FileReader(file)); buffer=new char[(int)file.length()]; int i=0; int c=bufferedReader.read(); while (c != -1) { buffer[i++]=(char)c; c=bufferedReader.read(); } bufferedReader.close(); return xstream.fromXML(new String(buffer)); } else throw new IOException("Can not find file - " + XMLfile); }
Example 41
From project anarchyape, under directory /src/main/java/ape/.
Source file: NetworkDisconnectCommand.java

/** * This method writes to the Stand output */ private boolean writeSTDOut(Process p){ BufferedReader stdInput=new BufferedReader(new InputStreamReader(p.getInputStream())); int count; CharBuffer cbuf=CharBuffer.allocate(99999); try { count=stdInput.read(cbuf); if (count != -1) cbuf.array()[count]='\0'; else if (cbuf.array()[0] != '\0') count=cbuf.array().length; else count=0; for (int i=0; i < count; i++) System.out.print(cbuf.get(i)); } catch ( IOException e) { System.err.println("Writing Stdout in NetworkDisconnectCommand catches an exception, Turn on the VERBOSE flag to see the stack trace"); e.printStackTrace(); return false; } try { stdInput.close(); } catch ( IOException e) { System.err.println("Unable to close the IOStream"); e.printStackTrace(); return false; } return true; }
Example 42
From project and-bible, under directory /AndBackendTest/src/net/bible/android/.
Source file: TestUtil.java

public static String convertStreamToString(InputStream is) throws IOException { if (is != null) { StringBuilder sb=new StringBuilder(); String line; try { BufferedReader reader=new BufferedReader(new InputStreamReader(is,"UTF-8")); while ((line=reader.readLine()) != null) { sb.append(line).append("\n"); } } finally { is.close(); } return sb.toString(); } else { return ""; } }
Example 43
From project andlytics, under directory /src/com/github/andlyticsproject/.
Source file: DeveloperConsole.java

private String getGwtRpcResponse(String developerPostData,URL aURL) throws IOException, ProtocolException, ConnectException { String result; HttpsURLConnection connection=(HttpsURLConnection)aURL.openConnection(); connection.setHostnameVerifier(new AllowAllHostnameVerifier()); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("POST"); connection.setConnectTimeout(4000); connection.setRequestProperty("Host","play.google.com"); connection.setRequestProperty("User-Agent","Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13"); connection.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); connection.setRequestProperty("Accept-Language","en-us,en;q=0.5"); connection.setRequestProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"); connection.setRequestProperty("Keep-Alive","115"); connection.setRequestProperty("Cookie",cookie); connection.setRequestProperty("Connection","keep-alive"); connection.setRequestProperty("Content-Type","text/x-gwt-rpc; charset=utf-8"); connection.setRequestProperty("X-GWT-Permutation",getGwtPermutation()); connection.setRequestProperty("X-GWT-Module-Base","https://play.google.com/apps/publish/gwt-play/"); connection.setRequestProperty("Referer","https://play.google.com/apps/publish/Home"); OutputStreamWriter streamToAuthorize=new java.io.OutputStreamWriter(connection.getOutputStream()); streamToAuthorize.write(developerPostData); streamToAuthorize.flush(); streamToAuthorize.close(); InputStream resultStream=connection.getInputStream(); BufferedReader aReader=new java.io.BufferedReader(new java.io.InputStreamReader(resultStream)); StringBuffer aResponse=new StringBuffer(); String aLine=aReader.readLine(); while (aLine != null) { aResponse.append(aLine + "\n"); aLine=aReader.readLine(); } resultStream.close(); result=aResponse.toString(); return result; }
Example 44
From project Android, under directory /integration-tests/src/main/java/com/github/mobile/tests/commit/.
Source file: DiffStylerTest.java

private void compareStyled(String patch) throws IOException { assertNotNull(patch); String fileName="file.txt"; DiffStyler styler=new DiffStyler(getContext().getResources()); CommitFile file=new CommitFile(); file.setFilename(fileName); file.setPatch(patch); styler.setFiles(Collections.singletonList(file)); List<CharSequence> styled=styler.get(fileName); assertNotNull(styled); BufferedReader reader=new BufferedReader(new StringReader(patch)); String line=reader.readLine(); int processed=0; while (line != null) { assertEquals(line,styled.get(processed).toString()); line=reader.readLine(); processed++; } assertEquals(processed,styled.size()); }
Example 45
From project android-client, under directory /xwiki-android-rest/src/org/xwiki/android/rest/.
Source file: HttpConnector.java

/** * Perform HTTP Get method execution and return the response as a String * @param Uri URL of XWiki RESTful API * @return Response data of the HTTP connection as a String */ public String getResponse(String Uri) throws RestConnectionException, RestException { initialize(); BufferedReader in=null; HttpGet request=new HttpGet(); String responseText=new String(); try { requestUri=new URI(Uri); } catch ( URISyntaxException e) { e.printStackTrace(); } setCredentials(); request.setURI(requestUri); Log.d("GET Request URL",Uri); try { response=client.execute(request); Log.d("Response status",response.getStatusLine().toString()); in=new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb=new StringBuffer(""); String line=""; String NL=System.getProperty("line.separator"); while ((line=in.readLine()) != null) { sb.append(line + NL); } in.close(); responseText=sb.toString(); Log.d("Response","response: " + responseText); validate(response.getStatusLine().getStatusCode()); } catch ( ClientProtocolException e) { e.printStackTrace(); } catch ( IOException e) { e.printStackTrace(); throw new RestConnectionException(e); } return responseText; }
Example 46
@Override protected Dialog onCreateDialog(int id){ switch (id) { case DIALOG_CHANGELOG: StringBuilder changelog=new StringBuilder(); BufferedReader input; try { InputStream is=getResources().openRawResource(R.raw.changelog); input=new BufferedReader(new InputStreamReader(is)); String line; while ((line=input.readLine()) != null) { changelog.append(line); changelog.append("<br/>"); } input.close(); } catch (IOException e) { e.printStackTrace(); } return new AlertDialog.Builder(this).setTitle(R.string.changelog_title).setMessage(Html.fromHtml(changelog.toString())).setPositiveButton(R.string.close,null).create(); } return null; }
Example 47
From project Android-Flashcards, under directory /src/com/secretsockssoftware/androidflashcards/.
Source file: AndroidFlashcards.java

static protected Lesson parseCSV(File file,String default_name) throws Exception { ArrayList<Card> cardList=new ArrayList<Card>(); BufferedReader br=new BufferedReader(new FileReader(file)); boolean first=true; String name=default_name; String desc="[no description]"; String line; String[] toks; CSVParser parser=new CSVParser(); while ((line=br.readLine()) != null) { line=line.trim(); if (line.length() <= 0) continue; try { toks=parser.parseLine(line); } catch ( IOException e) { Log.e(TAG,"Invalid line: " + line + " ("+ e.getMessage()+ ")"); continue; } if (toks.length < 2) { Log.e(TAG,"Warning, invalid line, not enough fields: " + line); continue; } if (toks.length > 2) Log.e(TAG,"Warning, too many fields on a line, ignoring all but the first two: " + line); if (first) { name=toks[0].trim(); desc=toks[1].trim(); first=false; } else { String front=toks[0].trim(); front=front.replaceAll("\\\\n","\n"); String back=toks[1].trim(); back=back.replaceAll("\\\\n","\n"); cardList.add(new Card(front,back)); } } return new Lesson(cardList.toArray(new Card[0]),name,desc); }
Example 48
From project Android-RTMP, under directory /android-ffmpeg-prototype/src/com/camundo/media/pipe/.
Source file: FFMPEGAudioInputPipe.java

@Override public void run(){ try { InputStreamReader isr=new InputStreamReader(inputStream); BufferedReader br=new BufferedReader(isr,32); String line; while ((line=br.readLine()) != null) { if (line.indexOf(IO_ERROR) != -1) { Log.e(TAG,"IOERRRRRORRRRR -> putting to processStartFailed"); processStartFailed=true; } } } catch ( Exception e) { e.printStackTrace(); } }
Example 49
From project android-share-menu, under directory /src/com/eggie5/.
Source file: post_to_eggie5.java

private void SendRequest(String data_string){ try { String xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<photo><photo>" + data_string + "</photo><caption>via android - "+ new Date().toString()+ "</caption></photo>"; String hostname="eggie5.com"; String path="/photos"; int port=80; InetAddress addr=InetAddress.getByName(hostname); Socket sock=new Socket(addr,port); BufferedWriter wr=new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8")); wr.write("POST " + path + " HTTP/1.1\r\n"); wr.write("Host: eggie5.com\r\n"); wr.write("Content-Length: " + xmldata.length() + "\r\n"); wr.write("Content-Type: text/xml; charset=\"utf-8\"\r\n"); wr.write("Accept: text/xml\r\n"); wr.write("\r\n"); wr.write(xmldata); wr.flush(); BufferedReader rd=new BufferedReader(new InputStreamReader(sock.getInputStream())); String line; while ((line=rd.readLine()) != null) { Log.v(this.getClass().getName(),line); } } catch ( Exception e) { Log.e(this.getClass().getName(),"Upload failed",e); } }
Example 50
From project Android-SyncAdapter-JSON-Server-Example, under directory /src/com/puny/android/network/util/.
Source file: DrupalJSONServerNetworkUtilityBase.java

protected static String convertStreamToString(InputStream is){ BufferedReader reader=new BufferedReader(new InputStreamReader(is)); StringBuilder sb=new StringBuilder(); String line=null; try { while ((line=reader.readLine()) != null) { sb.append(line + "\n"); } } catch ( IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch ( IOException e) { e.printStackTrace(); } } return sb.toString(); }
Example 51
From project android-thaiime, under directory /latinime/src/com/sugree/inputmethod/latin/.
Source file: Utils.java

public void printAll(){ mLoggingHandler.post(new Runnable(){ @Override public void run(){ mWriter.flush(); StringBuilder sb=new StringBuilder(); BufferedReader br=getBufferedReader(); String line; try { while ((line=br.readLine()) != null) { sb.append('\n'); sb.append(line); } } catch ( IOException e) { Log.e(USABILITY_TAG,"Can't read log file."); } finally { if (LatinImeLogger.sDBG) { Log.d(USABILITY_TAG,"output all logs\n" + sb.toString()); } mIms.getCurrentInputConnection().commitText(sb.toString(),0); try { br.close(); } catch ( IOException e) { } } } } ); }
Example 52
From project android-xbmcremote, under directory /src/org/xbmc/android/util/.
Source file: MacAddressResolver.java

private String arpResolve(String host){ System.out.println("ARPRESOLVE HOST: " + host); try { InetAddress inet=InetAddress.getByName(host); inet.isReachable(500); String ipString=inet.getHostAddress(); BufferedReader br=new BufferedReader(new FileReader("/proc/net/arp")); String line=""; while (true) { line=br.readLine(); if (line == null) break; if (line.startsWith(ipString)) { br.close(); System.out.println("ARPRESOLVE MAC:\n" + line); return line.split("\\s+")[3]; } } br.close(); return ""; } catch ( Exception e) { return ""; } }
Example 53
From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/util/.
Source file: ImportUtilities.java

public static ArrayList<String> loadItems() throws IOException { ArrayList<String> list=new ArrayList<String>(); File importFile=IOUtilities.getExternalFile(IMPORT_FILE); if (!importFile.exists()) return list; BufferedReader in=null; try { in=new BufferedReader(new InputStreamReader(new FileInputStream(importFile)),IOUtilities.IO_BUFFER_SIZE); String line; in.readLine(); while ((line=in.readLine()) != null) { final int index=line.indexOf('\t'); final int length=line.length(); if (index == -1 && length > 0) { list.add(line); } else if (index != length - 1) { list.add(line.substring(index + 1)); } else { list.add(line.substring(0,index)); } } } finally { IOUtilities.closeStream(in); } return list; }
Example 54
From project AndroidLab, under directory /samples/AndroidLdapClient/src/com/unboundid/android/ldap/client/.
Source file: ServerInstance.java

/** * Retrieves a map of all defined server instances, mapped from the instance ID to the instance object. * @param context The application context. It must not be {@code null}. * @return A map of all defined server instances. * @throws IOException If a problem occurs while reading information aboutthe defined instances. */ public static Map<String,ServerInstance> getInstances(final Context context) throws IOException { logEnter(LOG_TAG,"getInstances",context); final LinkedHashMap<String,ServerInstance> instances=new LinkedHashMap<String,ServerInstance>(1); BufferedReader reader=null; try { try { logDebug(LOG_TAG,"getInstances","Attempting to open file {0} for reading",INSTANCE_FILE_NAME); reader=new BufferedReader(new InputStreamReader(context.openFileInput(INSTANCE_FILE_NAME)),1024); } catch ( final FileNotFoundException fnfe) { logException(LOG_TAG,"getInstances",fnfe); return logReturn(LOG_TAG,"getInstances",Collections.unmodifiableMap(instances)); } while (true) { final String line=reader.readLine(); logDebug(LOG_TAG,"getInstances","read line {0}",line); if (line == null) { break; } if (line.length() == 0) { continue; } final ServerInstance i=decode(line); instances.put(i.getID(),i); } return logReturn(LOG_TAG,"getInstances",Collections.unmodifiableMap(instances)); } finally { if (reader != null) { logDebug(LOG_TAG,"getInstances","closing reader"); reader.close(); } } }
Example 55
From project androidtracks, under directory /src/org/sfcta/cycletracks/.
Source file: TripUploader.java

private static String convertStreamToString(InputStream is){ BufferedReader reader=new BufferedReader(new InputStreamReader(is)); StringBuilder sb=new StringBuilder(); String line=null; try { while ((line=reader.readLine()) != null) { sb.append(line + "\n"); } } catch ( IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch ( IOException e) { e.printStackTrace(); } } return sb.toString(); }
Example 56
From project androidZenWriter, under directory /src/com/javaposse/android/zenwriter/.
Source file: AndroidZenWriterActivity.java

protected void loadFile(String filename){ FileInputStream fis=null; BufferedReader br=null; File file=getFileStreamPath(filename); StringBuilder content=new StringBuilder(); if (file.exists()) { EditText editText=(EditText)findViewById(R.id.editText1); try { fis=openFileInput(filename); br=new BufferedReader(new InputStreamReader(fis)); while (br.ready()) { content.append(br.readLine()).append("\n"); } editText.setText(content.toString()); editText.setSelection(content.length()); } catch ( IOException e) { Log.e("SaveFile","Failed to save file: ",e); } finally { if (br != null) { try { br.close(); } catch ( IOException e) { } } if (fis != null) { try { fis.close(); } catch ( IOException e) { } } } } }
Example 57
From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.
Source file: DeviceInfoSettings.java

private String getFormattedKernelVersion(){ String procVersionStr; try { BufferedReader reader=new BufferedReader(new FileReader("/proc/version"),256); try { procVersionStr=reader.readLine(); } finally { reader.close(); } final String PROC_VERSION_REGEX="\\w+\\s+" + "\\w+\\s+" + "([^\\s]+)\\s+"+ "\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+"+ "\\((?:[^(]*\\([^)]*\\))?[^)]*\\)\\s+"+ "([^\\s]+)\\s+"+ "(?:PREEMPT\\s+)?"+ "(.+)"; Pattern p=Pattern.compile(PROC_VERSION_REGEX); Matcher m=p.matcher(procVersionStr); if (!m.matches()) { Log.e(TAG,"Regex did not match on /proc/version: " + procVersionStr); return "Unavailable"; } else if (m.groupCount() < 4) { Log.e(TAG,"Regex match on /proc/version only returned " + m.groupCount() + " groups"); return "Unavailable"; } else { return (new StringBuilder(m.group(1)).append("\n").append(m.group(2)).append(" ").append(m.group(3)).append("\n").append(m.group(4))).toString(); } } catch ( IOException e) { Log.e(TAG,"IO Exception when getting kernel version for Device Info screen",e); return "Unavailable"; } }
Example 58
From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.
Source file: CPUActivity.java

public static String readOneLine(String fname){ BufferedReader br; String line=null; try { br=new BufferedReader(new FileReader(fname),512); try { line=br.readLine(); } finally { br.close(); } } catch ( Exception e) { Log.e(TAG,"IO Exception when reading /sys/ file",e); } return line; }
Example 59
From project android_packages_apps_FileManager, under directory /src/org/openintents/distribution/.
Source file: EulaActivity.java

/** * Read license from raw resource. * @param resourceid ID of the raw resource. * @return */ String readTextFromRawResource(int resourceid,boolean preserveLineBreaks){ String license=""; Resources resources=getResources(); BufferedReader in=new BufferedReader(new InputStreamReader(resources.openRawResource(resourceid))); String line; StringBuilder sb=new StringBuilder(); try { while ((line=in.readLine()) != null) { if (TextUtils.isEmpty(line)) { sb.append("\n\n"); } else { sb.append(line); if (preserveLineBreaks) { sb.append("\n"); } else { sb.append(" "); } } } license=sb.toString(); } catch ( IOException e) { e.printStackTrace(); } return license; }
Example 60
From project android_packages_apps_SalvageParts, under directory /src/com/salvagemod/salvageparts/activities/.
Source file: PerformanceActivity.java

public static String readOneLine(String fname){ BufferedReader br; String line=null; try { br=new BufferedReader(new FileReader(fname),512); try { line=br.readLine(); } finally { br.close(); } } catch ( Exception e) { Log.e(TAG,"IO Exception when reading /sys/ file",e); } return line; }
Example 61
From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.
Source file: InfoFragment.java

@Override protected Void doInBackground(Void... arg){ publishProgress(0,Util.getSuperuserVersionInfo(getActivity())); publishProgress(1,Util.elitePresent(getActivity(),false,0)); String suPath=Util.whichSu(); if (suPath != null) { publishProgress(2,Util.getSuVersionInfo()); String suTools=Util.ensureSuTools(getActivity()); try { Process process=new ProcessBuilder(suTools,"ls","-l",suPath).redirectErrorStream(true).start(); BufferedReader is=new BufferedReader(new InputStreamReader(process.getInputStream())); process.waitFor(); String inLine=is.readLine(); String bits[]=inLine.split("\\s+"); publishProgress(3,bits[0],String.format("%s %s",bits[1],bits[2]),suPath); } catch ( IOException e) { Log.w(TAG,"Binary information could not be read"); } catch ( InterruptedException e) { e.printStackTrace(); } } else { publishProgress(2,null); } SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getActivity()); publishProgress(4,prefs.getBoolean(Preferences.OUTDATED_NOTIFICATION,true)); if (mDevice == null) mDevice=new Device(getActivity()); mDevice.analyzeSu(); boolean supported=mDevice.mFileSystem == FileSystem.EXTFS; if (!supported) { publishProgress(5,null); } else { publishProgress(5,mDevice.isRooted,mDevice.isSuProtected); } return null; }
Example 62
From project android_packages_apps_VoiceDialer_2, under directory /src/com/android/voicedialer/.
Source file: VoiceContact.java

/** * @param contactsFile File containing a list of names,one per line. * @return a List of {@link VoiceContact} in a File. */ public static List<VoiceContact> getVoiceContactsFromFile(File contactsFile){ if (false) Log.d(TAG,"getVoiceContactsFromFile " + contactsFile); List<VoiceContact> contacts=new ArrayList<VoiceContact>(); BufferedReader br=null; try { br=new BufferedReader(new FileReader(contactsFile),8192); String name; for (int id=1; (name=br.readLine()) != null; id++) { contacts.add(new VoiceContact(name,id,ID_UNDEFINED,ID_UNDEFINED,ID_UNDEFINED,ID_UNDEFINED,ID_UNDEFINED)); } } catch ( IOException e) { if (false) Log.d(TAG,"getVoiceContactsFromFile failed " + e); } finally { try { br.close(); } catch ( IOException e) { if (false) Log.d(TAG,"getVoiceContactsFromFile failed during close " + e); } } if (false) Log.d(TAG,"getVoiceContactsFromFile " + contacts.size()); return contacts; }
Example 63
From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/latin/.
Source file: Utils.java

public void printAll(){ mLoggingHandler.post(new Runnable(){ @Override public void run(){ mWriter.flush(); StringBuilder sb=new StringBuilder(); BufferedReader br=getBufferedReader(); String line; try { while ((line=br.readLine()) != null) { sb.append('\n'); sb.append(line); } } catch ( IOException e) { Log.e(USABILITY_TAG,"Can't read log file."); } finally { if (LatinImeLogger.sDBG) { Log.d(USABILITY_TAG,"output all logs\n" + sb.toString()); } mIms.getCurrentInputConnection().commitText(sb.toString(),0); try { br.close(); } catch ( IOException e) { } } } } ); }
Example 64
/** * Converts an InputStream to a String. * @param is InputStream to convert * @return String version of the InputStream */ public static String convertStreamToString(InputStream is){ String contentOfMyInputStream=""; try { BufferedReader rd=new BufferedReader(new InputStreamReader(is),4096); String line; StringBuilder sb=new StringBuilder(); while ((line=rd.readLine()) != null) { sb.append(line); } rd.close(); contentOfMyInputStream=sb.toString(); } catch ( Exception e) { e.printStackTrace(); } return contentOfMyInputStream; }
Example 65
From project ANNIS, under directory /annis-service/src/main/java/annis/administration/.
Source file: AnnisAdminRunner.java

private void usage(String error){ Resource resource=new ClassPathResource("annis/administration/usage.txt"); BufferedReader reader=null; try { reader=new BufferedReader(new InputStreamReader(resource.getInputStream(),"UTF-8")); for (String line=reader.readLine(); line != null; line=reader.readLine()) { System.out.println(line); } } catch ( IOException e) { log.warn("could not read usage information: " + e.getMessage()); } finally { if (reader != null) { try { reader.close(); } catch ( IOException ex) { log.error(null,ex); } } } if (error != null) { error(error); } }
Example 66
From project annotare2, under directory /app/magetab/src/main/java/uk/ac/ebi/fg/annotare2/magetab/base/.
Source file: TsvParser.java

public Table parse(InputStream in) throws IOException { init(); BufferedReader br=null; try { br=new BufferedReader(new InputStreamReader(in,Charsets.UTF_8)); String line; while ((line=br.readLine()) != null) { processLine(line); } } finally { closeQuietly(br); } if (!stats.isReadable()) { throw new IOException("The file content doesn't look like a text"); } return table; }
Example 67
From project AntiCheat, under directory /src/main/java/net/h31ix/anticheat/util/yaml/.
Source file: CommentedConfiguration.java

@Override public void load(InputStream stream) throws IOException, InvalidConfigurationException { InputStreamReader reader=new InputStreamReader(stream); StringBuilder builder=new StringBuilder(); BufferedReader input=new BufferedReader(reader); try { String line; int i=0; while ((line=input.readLine()) != null) { i++; if (line.contains(COMMENT_PREFIX)) { comments.put(i,line); } builder.append(line); builder.append('\n'); } } finally { input.close(); } loadFromString(builder.toString()); }
Example 68
From project apollo, under directory /injector/src/main/java/com/bskyb/cg/environments/server/.
Source file: LogServer.java

public void run(){ try { InputStream input=clientSocket.getInputStream(); OutputStream output=clientSocket.getOutputStream(); BufferedReader is=new BufferedReader(new InputStreamReader(input)); String line; line=is.readLine(); messageHandler.processMessage(line.getBytes()); output.close(); input.close(); } catch ( IOException e) { logger.error("Exception in LogServer",e); } }
Example 69
From project apps-for-android, under directory /Panoramio/src/com/google/android/panoramio/.
Source file: ImageManager.java

private String convertStreamToString(InputStream is){ BufferedReader reader=new BufferedReader(new InputStreamReader(is),8 * 1024); StringBuilder sb=new StringBuilder(); String line=null; try { while ((line=reader.readLine()) != null) { sb.append(line + "\n"); } } catch ( IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch ( IOException e) { e.printStackTrace(); } } return sb.toString(); }
Example 70
From project action-core, under directory /src/main/java/com/ning/metrics/action/hdfs/data/.
Source file: RowTextFileContentsIterator.java

public RowTextFileContentsIterator(final String pathname,final RowParser rowParser,final Registrar registrar,final InputStream origStream,final boolean rawContents) throws IOException { super(pathname,rowParser,registrar,rawContents); final String[] tokenizedPathname=StringUtils.split(pathname,"."); String suffix=tokenizedPathname[tokenizedPathname.length - 1]; final InputStream stream=DecompressedStreamFactory.wrapStream(suffix,origStream); if (stream != null) { in=stream; suffix=tokenizedPathname[tokenizedPathname.length - 2]; } else { in=origStream; } binary=suffix.equals("smile") || suffix.equals("thrift"); if (suffix.equals("smile")) { reader=null; streamReader=new BufferedSmileReader(registrar,in); } else if (suffix.equals("thrift")) { reader=null; streamReader=new BufferedThriftReader(registrar,in); } else { streamReader=null; reader=new BufferedReader(new InputStreamReader(in)); } }
Example 71
From project aksunai, under directory /src/org/androidnerds/app/aksunai/net/.
Source file: ConnectionThread.java

public void run(){ try { if (AppConstants.DEBUG) Log.d(AppConstants.NET_TAG,"Connecting to... " + mServerDetail.mUrl + ":"+ mServerDetail.mPort); mSock=new Socket(mServerDetail.mUrl,mServerDetail.mPort); } catch ( UnknownHostException e) { if (AppConstants.DEBUG) Log.d(AppConstants.NET_TAG,"UnknownHostException caught, terminating connection process"); } catch ( IOException e) { if (AppConstants.DEBUG) Log.d(AppConstants.NET_TAG,"IOException caught on socket creation. (Server) " + mServer + ", (Exception) "+ e.toString()); } try { mWriter=new BufferedWriter(new OutputStreamWriter(mSock.getOutputStream())); mReader=new BufferedReader(new InputStreamReader(mSock.getInputStream())); } catch ( IOException e) { if (AppConstants.DEBUG) Log.d(AppConstants.NET_TAG,"IOException caught grabbing input/output streams. (Server) " + mServer + ", (Exception) "+ e.toString()); } mServer.init(mServerDetail.mPass,mServerDetail.mNick,mServerDetail.mUser,mServerDetail.mRealName); try { while (!shouldKill()) { String message=mReader.readLine(); if (AppConstants.DEBUG) Log.d(AppConstants.NET_TAG,"Received message: " + message); mServer.receiveMessage(message); } } catch ( IOException e) { if (AppConstants.DEBUG) Log.d(AppConstants.NET_TAG,"IOException caught handling messages. (Server) " + mServer + ", (Exception) "+ e.toString()); } return; }