Java Code Examples for java.io.InputStream#toString()
The following examples show how to use
java.io.InputStream#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DOMConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** Configure log4j by reading in a log4j.dtd compliant XML configuration file. */ public void doConfigure(final InputStream inputStream, LoggerRepository repository) throws FactoryConfigurationError { ParseAction action = new ParseAction() { public Document parse(final DocumentBuilder parser) throws SAXException, IOException { InputSource inputSource = new InputSource(inputStream); inputSource.setSystemId("dummy://log4j.dtd"); return parser.parse(inputSource); } public String toString() { return "input stream [" + inputStream.toString() + "]"; } }; doConfigure(action, repository); }
Example 2
Source File: GraphExecuter.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public void loadGraph(final InputStream fileStream, final File file, final boolean addUI, final boolean wait) throws GraphException { try { if (fileStream == null) return; final LoadGraphThread loadGraphThread = new LoadGraphThread(fileStream, addUI); loadGraphThread.execute(); if(wait) { loadGraphThread.get(); } lastLoadedGraphFile = file; } catch (Throwable e) { throw new GraphException("Unable to load graph " + fileStream.toString() + '\n' + e.getMessage()); } }
Example 3
Source File: AbstractBuiltInFunctionTable.java From intellij-xquery with Apache License 2.0 | 6 votes |
private List<String> getAllLines(InputStream resource) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resource)); try { List<String> lines = new ArrayList<String>(); String line; while ((line = bufferedReader.readLine()) != null) { lines.add(line); } return lines; } catch (IOException e) { throw new RuntimeException("Unable to read bif file " + resource.toString(), e); } finally { try { bufferedReader.close(); } catch (IOException ignored) { } } }
Example 4
Source File: YamlSourceTest.java From configuration-as-code-plugin with MIT License | 5 votes |
@Test public void shouldUseToStringOfSourceInToStringForInputStream() { //given InputStream testInputStream = new ByteArrayInputStream("IS content".getBytes(StandardCharsets.UTF_8)); String testInputStreamToString = testInputStream.toString(); //and YamlSource<InputStream> yamlSource = YamlSource.of(testInputStream); //expect assertEquals("YamlSource: " + testInputStreamToString, yamlSource.toString()); }
Example 5
Source File: RowColumnResourcesImpl.java From smartsheet-java-sdk with Apache License 2.0 | 5 votes |
private void addImage(String path, InputStream inputStream, String contentType, long contentLength, boolean overrideValidation, String altText, String imageName) throws SmartsheetException { if(imageName == null) { inputStream.toString(); } if(contentType == null) { contentType = "application/octet-stream"; } HashMap<String, Object> parameters = new HashMap<String, Object>(); if(altText != null) { parameters.put("altText", altText); } if(overrideValidation) { parameters.put("overrideValidation", "true"); } path += QueryUtil.generateUrl(null, parameters); HttpRequest request = createHttpRequest(this.smartsheet.getBaseURI().resolve(path), HttpMethod.POST); try { request.getHeaders().put("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(imageName, "UTF-8") + "\""); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } HttpEntity entity = new HttpEntity(); entity.setContentType(contentType); entity.setContent(inputStream); entity.setContentLength(contentLength); request.setEntity(entity); HttpResponse response = this.smartsheet.getHttpClient().request(request); switch (response.getStatusCode()) { case 200: break; default: handleError(response); } smartsheet.getHttpClient().releaseConnection(); }
Example 6
Source File: GetNAF.java From EventCoreference with Apache License 2.0 | 5 votes |
public static String getText(String stringUrl) throws Exception { //stringUrl = "https://knowledgestore2.fbk.eu/nwr/cars3/files?id=%3Chttp%3A%2F%2Fwww.newsreader-project.eu%2Fdata%2Fcars%2F2004%2F10%2F18%2F4DKT-30W0-00S0-W39B.xml.naf%3E"; URL url = new URL(stringUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); // connection.setRequestProperty("Accept", "application/xml"); connection.setRequestProperty("Accept", "application/octet-stream"); InputStream xml = connection.getInputStream(); String rawText = xml.toString(); return rawText; }