Java Examples for java.io.InputStream

The following java examples will help you to understand the usage of java.io.InputStream. These source code samples are taken from different open source projects.

Example 1
Project: pojobuilder-master  File: InputSourceBuilder.java View source code
/**
   * Creates a new {@link InputSource} based on this builder's settings.
   *
   * @return the created InputSource
   */
public InputSource build() {
    try {
        InputSource result = InputSourceFactory.createInputSource(value$byteStream$java$io$InputStream);
        if (isSet$encoding$java$lang$String) {
            result.setEncoding(value$encoding$java$lang$String);
        }
        return result;
    } catch (RuntimeException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new java.lang.reflect.UndeclaredThrowableException(ex);
    }
}
Example 2
Project: mozu-java-master  File: PackageClient.java View source code
/**
	 * appdev-filebasedpackage Get GetFile description DOCUMENT_HERE 
	 * <p><pre><code>
	 * MozuClient<java.io.InputStream> mozuClient=GetFileClient( applicationKey,  fileName);
	 * client.setBaseAddress(url);
	 * client.executeRequest();
	 * Stream stream = client.Result();
	 * </code></pre></p>
	 * @param applicationKey The application key uniquely identifies the developer namespace, application ID, version, and package in Dev Center. The format is {Dev Account namespace}.{Application ID}.{Application Version}.{Package name}. 
	 * @param fileName 
	 * @return Mozu.Api.MozuClient <Stream>
	 * @see Stream
	 */
public static MozuClient<java.io.InputStream> getFileClient(String applicationKey, String fileName) throws Exception {
    MozuUrl url = com.mozu.api.urls.platform.appdev.PackageUrl.getFileUrl(applicationKey, fileName);
    String verb = "GET";
    Class<?> clz = java.io.InputStream.class;
    MozuClient<java.io.InputStream> mozuClient = (MozuClient<java.io.InputStream>) MozuClientFactory.getInstance(clz);
    mozuClient.setVerb(verb);
    mozuClient.setResourceUrl(url);
    return mozuClient;
}
Example 3
Project: jdroid-master  File: CacheParser.java View source code
/**
	 * @see Parser#parse(java.io.InputStream)
	 */
@Override
public Object parse(InputStream inputStream) {
    final InputStream inputStreamCopy = FileUtils.copy(inputStream);
    Object object = parser.parse(inputStreamCopy);
    ExecutorUtils.execute(new Runnable() {

        @Override
        public void run() {
            try {
                inputStreamCopy.reset();
            } catch (IOException e) {
                LoggerUtils.logHandledException(LOGGER, e);
            }
            FileUtils.copyStream(inputStreamCopy, cacheFile);
            LOGGER.debug("Saved http request to cache file: " + cacheFile.getAbsolutePath());
        }
    });
    return object;
}
Example 4
Project: pcl-parser-master  File: CmdComment.java View source code
/*
   * (non-Javadoc)
   * 
   * @see
   * com.ccginc.pcl5.HPGLInterpreter.cmd.CommandHPGL#execute(java.io.InputStream
   * )
   */
protected void execute(InputStream in) throws IOException {
    char c = (char) in.read();
    while (c != '"') // first quote
    c = (char) in.read();
    StringBuilder sb = new StringBuilder();
    c = (char) in.read();
    while (// end quote
    c != '"') {
        sb.append(c);
        c = (char) in.read();
    }
    _printerState.trace(this, sb.toString());
}
Example 5
Project: acfun-new-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 6
Project: ache-master  File: CrawlerCommons.java View source code
public static String getVersion() {
    String path = "/version.prop";
    InputStream stream = CrawlerCommons.class.getResourceAsStream(path);
    if (stream == null) {
        return "Unknown Version";
    }
    Properties props = new Properties();
    try {
        props.load(stream);
        stream.close();
        return (String) props.get("version");
    } catch (IOException e) {
        return "Unknown Version";
    }
}
Example 7
Project: actionbar-sherlock-viewpager-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 8
Project: Android-Backup-master  File: TestHelper.java View source code
public static String getResource(String name) throws IOException {
    final InputStream resourceAsStream = TestHelper.class.getResourceAsStream(name);
    assert (resourceAsStream != null);
    int n;
    byte[] buffer = new byte[8192];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    while ((n = resourceAsStream.read(buffer)) != -1) {
        bos.write(buffer, 0, n);
    }
    return new String(bos.toByteArray());
}
Example 9
Project: android-playlistr-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 10
Project: androidPublish-master  File: Strings.java View source code
public static String fromStream(InputStream inputStream) throws IOException {
    int numberBytesRead = 0;
    StringBuilder out = new StringBuilder();
    byte[] bytes = new byte[4096];
    while (numberBytesRead != -1) {
        out.append(new String(bytes, 0, numberBytesRead));
        numberBytesRead = inputStream.read(bytes);
    }
    inputStream.close();
    return out.toString();
}
Example 11
Project: AndroidStore-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 12
Project: Android_App_OpenSource-master  File: StreamUtils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 13
Project: appengine-endpoints-booking-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 14
Project: ARKOST-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 15
Project: arquillian-showcase-master  File: StreamReaderUtil.java View source code
public static String readAllAndClose(InputStream is) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        int read;
        while ((read = is.read()) != -1) {
            out.write(read);
        }
    } finally {
        try {
            is.close();
        } catch (Exception e) {
        }
    }
    return out.toString();
}
Example 16
Project: bundles-master  File: Test.java View source code
public static void main(String[] args) throws Exception {
    System.out.println("Helo world");
    URL url = new URL("https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles/aQute.libg/aQute.libg-2.8.0.jar");
    InputStream in = url.openStream();
    System.out.println("got " + in);
    System.out.println("Helo world");
}
Example 17
Project: CareAndroid-master  File: StreamTool.java View source code
public static String inputStreamToString(InputStream in) throws Exception {
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    byte[] data = new byte[BUFFER_SIZE];
    int count = -1;
    while ((count = in.read(data, 0, BUFFER_SIZE)) != -1) outStream.write(data, 0, count);
    data = null;
    return new String(outStream.toByteArray(), "ISO-8859-1");
}
Example 18
Project: centipede-master  File: Version.java View source code
public static String get(String packageName) {
    String lookFor = "/" + packageName.replace(".", "/") + "/version.properties";
    InputStream in = Version.class.getResourceAsStream(lookFor);
    Properties p = new Properties();
    try {
        p.load(in);
    } catch (IOException e) {
        return null;
    }
    return p.getProperty(packageName + ".version");
}
Example 19
Project: dip-master  File: TestProperties.java View source code
public static void main(String[] args) throws IOException {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    InputStream resourceStream = loader.getResourceAsStream("job.properties");
    Properties prop = new Properties();
    prop.load(resourceStream);
    System.out.println(prop.getProperty("systems.hdfsDump.samza.factory"));
}
Example 20
Project: fanfoudroid-master  File: StreamUtils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 21
Project: Frescodemo-master  File: FileUtils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 22
Project: geoserver-master  File: RawMapTest.java View source code
@Test
public void testInputStream() throws Exception {
    InputStream stream = createMock(InputStream.class);
    expect(stream.read((byte[]) anyObject())).andReturn(-1).once();
    replay(stream);
    WMSMapContent map = createNiceMock(WMSMapContent.class);
    replay(map);
    new RawMap(map, stream, "text/plain").writeTo(null);
    verify(stream);
}
Example 23
Project: Harvest-Festival-master  File: ResourceLoader.java View source code
public static String getJSONResource(ResourceLocation id, String directory) {
    String s = id.getResourceDomain();
    String s1 = id.getResourcePath();
    InputStream inputstream = null;
    try {
        inputstream = ResourceLoader.class.getResourceAsStream("/assets/" + s + "/" + directory + "/" + s1 + ".json");
        return IOUtils.toString(inputstream);
    } catch (Throwable var10) {
    } finally {
        IOUtils.closeQuietly(inputstream);
    }
    return "";
}
Example 24
Project: hexa.tools-master  File: StreamTools.java View source code
public static boolean copyStream(InputStream input, OutputStream output) {
    try {
        int size = 4096;
        byte[] buffer = new byte[size];
        int read = 0;
        do {
            read = input.read(buffer);
            if (read > 0)
                output.write(buffer, 0, read);
        } while (read == size);
        return true;
    } catch (IOException e) {
        return false;
    }
}
Example 25
Project: hivedb-master  File: Converters.java View source code
public static byte[] getBytes(InputStream inputStream) {
    ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
    byte[] buffer = new byte[1024];
    int len;
    try {
        while ((len = inputStream.read(buffer)) >= 0) out.write(buffer, 0, len);
        inputStream.reset();
        out.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return out.toByteArray();
}
Example 26
Project: i-board-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 27
Project: intellij-community-master  File: ExceptionFromFinallyNesting.java View source code
private void run(int port) throws Exception {
    Socket socket = new Socket("localhost", port);
    try {
        InputStream inputReader = socket.getInputStream();
        try {
            OutputStream outputWriter = socket.getOutputStream();
            try {
                while (true) {
                    inputReader.read();
                }
            } finally {
                outputWriter.close();
            }
        } finally {
            inputReader.close();
        }
    } finally {
        socket.close();
    }
}
Example 28
Project: javamagic-master  File: TestUtils.java View source code
public 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);
        }
        is.close();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return sb.toString();
}
Example 29
Project: JavaStudy-master  File: TestClass.java View source code
public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.asiainfo.com/Portals/0/LogoHeader.png");
    InputStream is = url.openStream();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    byte[] buffer = new byte[4096];
    int n = 0;
    while (-1 != (n = is.read(buffer))) {
        output.write(buffer, 0, n);
    }
    System.out.println(output.toByteArray().length);
}
Example 30
Project: jcifs-krb5-master  File: GetURL.java View source code
public static void main(String argv[]) throws Exception {
    jcifs.Config.registerSmbURLHandler();
    URL url = new URL(argv[0]);
    InputStream in = url.openStream();
    if (in != null) {
        byte[] buf = new byte[4096];
        int n;
        while ((n = in.read(buf)) != -1) {
            System.out.write(buf, 0, n);
        }
    } else {
        System.out.println("stream waz null");
    }
    in.close();
}
Example 31
Project: jcifs-log4j-master  File: GetURL.java View source code
public static void main(String argv[]) throws Exception {
    jcifs.Config.registerSmbURLHandler();
    URL url = new URL(argv[0]);
    InputStream in = url.openStream();
    if (in != null) {
        byte[] buf = new byte[4096];
        int n;
        while ((n = in.read(buf)) != -1) {
            System.out.write(buf, 0, n);
        }
    } else {
        System.out.println("stream waz null");
    }
    in.close();
}
Example 32
Project: jcifs-master  File: GetURL.java View source code
public static void main(String argv[]) throws Exception {
    jcifs.Config.registerSmbURLHandler();
    URL url = new URL(argv[0]);
    InputStream in = url.openStream();
    if (in != null) {
        byte[] buf = new byte[4096];
        int n;
        while ((n = in.read(buf)) != -1) {
            System.out.write(buf, 0, n);
        }
    } else {
        System.out.println("stream waz null");
    }
    in.close();
}
Example 33
Project: jetty-plugin-support-master  File: StreamUtils.java View source code
public static String inputStreamToString(InputStream inputStream) throws IOException {
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
    StringBuilder stringBuilder = new StringBuilder();
    String line = null;
    while ((line = bufferedReader.readLine()) != null) {
        stringBuilder.append(line + "\n");
    }
    bufferedReader.close();
    return stringBuilder.toString();
}
Example 34
Project: JIkeDream-master  File: StremTools.java View source code
public static String readInputStrem(InputStream is) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    @SuppressWarnings("unused") int len = 0;
    byte[] buffer = new byte[1024];
    try {
        while ((len = is.read(buffer)) != -1) {
            baos.write(buffer);
        }
        is.close();
        baos.close();
        return new String(baos.toByteArray(), "UTF-8");
    } catch (Exception e) {
        e.printStackTrace();
        return "获�数�失败";
    }
}
Example 35
Project: JMOT-master  File: IO.java View source code
public static byte[] getBytes(InputStream inputStream) {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    while (true) {
        int len = 0;
        if (len < 0) {
            break;
        }
        try {
            len = inputStream.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (len < 0) {
            break;
        }
        bout.write(buffer, 0, len);
    }
    return bout.toByteArray();
}
Example 36
Project: Joomla-Day-Brasil-2011-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 37
Project: json-benchmarks-master  File: Helper.java View source code
public static String getResource(String name) {
    try (InputStream stream = Helper.class.getClassLoader().getResourceAsStream(name)) {
        try (Scanner scanner = new Scanner(stream)) {
            return scanner.useDelimiter("\\A").next();
        }
    } catch (IOException e) {
        throw new IllegalArgumentException("Error on resorce loading: " + name);
    }
}
Example 38
Project: kaorisan-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 39
Project: KarungGuniApp-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 40
Project: LazyList-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 41
Project: like_netease_news-master  File: CityService.java View source code
public String getCityJson() {
    String json = null;
    InputStream in = getClass().getClassLoader().getResourceAsStream("city.json");
    int len = 0;
    byte[] buffer = new byte[1024];
    StringBuffer sb = new StringBuffer();
    try {
        while ((len = in.read(buffer)) != -1) {
            sb.append(new String(buffer, 0, len));
        }
        json = sb.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return json;
}
Example 42
Project: mobile-client-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 43
Project: MusicDNA-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 44
Project: ONE_PIECE_OV-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 45
Project: Open-Vehicle-Android-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 46
Project: openjdk-master  File: DataFlavorComparatorTest1.java View source code
public static void main(String[] args) throws Exception {
    String[] mimes = new String[] { "text/plain;class=java.nio.ByteBuffer;charset=UTF-8", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-8", "text/plain;class=java.nio.ByteBuffer;charset=UTF-16LE", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16LE", "application/x-java-text-encoding", "application/x-java-serialized-object;class=java.lang.String", "text/plain;class=java.io.InputStream;charset=UTF-8", "text/uri-list;class=java.io.InputStream;charset=UTF-8", "text/plain;class=java.io.InputStream;charset=windows-1252", "text/uri-list;class=java.io.InputStream;charset=windows-1252", "application/x-java-url;class=java.net.URL", "text/plain;class=java.io.Reader", "text/plain;charset=windows-1252", "text/uri-list;class=java.io.Reader", "text/uri-list;charset=windows-1252", "text/plain;charset=UTF-8", "text/uri-list;charset=UTF-8", "text/plain;class=java.io.InputStream;charset=US-ASCII", "text/uri-list;class=java.io.InputStream;charset=US-ASCII", "text/plain;class=java.io.InputStream;charset=UTF-16LE", "text/plain;charset=US-ASCII", "text/uri-list;class=java.io.InputStream;charset=UTF-16LE", "text/uri-list;charset=US-ASCII", "text/plain;charset=UTF-16LE", "text/uri-list;charset=UTF-16LE", "text/plain;class=java.nio.ByteBuffer;charset=UTF-16BE", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16BE", "text/plain;class=java.nio.ByteBuffer;charset=ISO-8859-1", "text/uri-list;class=java.nio.ByteBuffer;charset=ISO-8859-1", "text/plain", "text/uri-list", "text/plain;class=java.nio.ByteBuffer;charset=UTF-16", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16", "text/plain;class=java.io.InputStream;charset=unicode", "text/uri-list;class=java.io.InputStream;charset=UTF-16", "text/plain;class=java.nio.CharBuffer", "text/uri-list;class=java.nio.CharBuffer", "text/plain;class=java.lang.String", "text/plain;charset=UTF-16BE", "text/uri-list;class=java.lang.String", "text/uri-list;charset=UTF-16BE", "text/plain;charset=ISO-8859-1", "text/uri-list;charset=ISO-8859-1", "text/plain;class=java.io.InputStream;charset=UTF-16BE", "text/uri-list;class=java.io.InputStream;charset=UTF-16BE", "text/plain;class=java.nio.ByteBuffer;charset=US-ASCII", "text/uri-list;class=java.nio.ByteBuffer;charset=US-ASCII", "text/plain;class=java.io.InputStream;charset=ISO-8859-1", "text/uri-list;class=java.io.InputStream;charset=ISO-8859-1", "text/plain;charset=UTF-16", "text/plain;class=java.nio.ByteBuffer;charset=windows-1252", "text/uri-list;charset=UTF-16", "text/uri-list;class=java.nio.ByteBuffer;charset=windows-1252", "text/plain;class=java.io.InputStream;charset=windows-1252", "text/uri-list;class=java.io.InputStream;charset=windows-1252" };
    DataFlavor[] flavors = new DataFlavor[mimes.length];
    for (int i = 0; i < flavors.length; i++) {
        flavors[i] = new DataFlavor(mimes[i]);
    }
    testComparator(DataFlavorUtil.getDataFlavorComparator(), flavors);
    System.out.println("Passed.");
}
Example 47
Project: OrderNowAndroid-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 48
Project: osgi.enroute-master  File: Test.java View source code
public static void main(String[] args) throws Exception {
    System.out.println("Helo world");
    URL url = new URL("https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles/aQute.libg/aQute.libg-2.8.0.jar");
    InputStream in = url.openStream();
    System.out.println("got " + in);
    System.out.println("Helo world");
}
Example 49
Project: osm-tools-master  File: PbfReaderTest.java View source code
@Test
public void testParse() throws Exception {
    DummyOsmProcessor osmProcessor = new DummyOsmProcessor();
    InputStream inputStream = PbfReaderTest.class.getClassLoader().getResourceAsStream("libya.osm.pbf");
    BlockInputStream bis = new BlockInputStream(inputStream, new OsmPbfParser(osmProcessor));
    bis.process();
    assertEquals(524781, osmProcessor.getNodes());
    assertEquals(51939, osmProcessor.getWays());
    assertEquals(81, osmProcessor.getRelations());
}
Example 50
Project: pps_android-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 51
Project: property-db-master  File: URLConnection_Connect_1.java View source code
public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.illinois.edu");
    URLConnection conn = url.openConnection();
    // The URLConnection is connected to the server.
    InputStream input = conn.getInputStream();
    // As URLConnection.connect() is called and the connection has already
    // been opened, the following call should trigger the property handler.
    conn.connect();
}
Example 52
Project: PullToRefreshStaggeredGridViewDemo-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 53
Project: query-master  File: Logging.java View source code
public static void reconfigure() {
    try {
        InputStream loggingProperties = Logging.class.getClassLoader().getResourceAsStream("logging.properties");
        LogManager.getLogManager().readConfiguration(loggingProperties);
    } catch (Exception e) {
        throw new RuntimeException("Failed to reconfigure Java Logging.", e);
    }
}
Example 54
Project: RapidFTR---BlackBerry-Edition-master  File: FileUtility.java View source code
public static byte[] getByteArray(String filename) {
    FileConnection fconn;
    try {
        fconn = (FileConnection) Connector.open(filename);
        InputStream input = fconn.openInputStream();
        byte[] data = new byte[(int) fconn.fileSize()];
        input.read(data, 0, data.length);
        return data;
    } catch (IOException e) {
        return null;
    }
}
Example 55
Project: rassyeyanie-master  File: SequentialTransformerTest.java View source code
@Test
public void process() throws Exception {
    System.out.println("Searching for resources:");
    String resource = "ca/uhn/hl7v2/parser/eventmap/2.4.properties";
    InputStream in = GenericListener.class.getClassLoader().getResourceAsStream(resource);
    Properties structures = null;
    structures = new Properties();
    structures.load(in);
    System.out.println(structures.size());
}
Example 56
Project: RCS-android-demo-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 57
Project: RMIT-Examples-master  File: Client.java View source code
public static void main(String[] args) {
    try {
        Socket s = new Socket("localhost", 10013);
        try {
            InputStream inStream = s.getInputStream();
            Scanner in = new Scanner(inStream);
            while (in.hasNextLine()) {
                System.out.println(in.nextLine());
            }
        } finally {
            s.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 58
Project: SecurePhoto-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 59
Project: senses-lbs-social-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 60
Project: sigmah-master  File: ConfigReader.java View source code
public static String getPropValues(String param, String filePath) {
    Properties prop = new Properties();
    try (InputStream inputStream = new FileInputStream(filePath)) {
        if (inputStream != null) {
            prop.load(inputStream);
        }
        return prop.getProperty(param);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Example 61
Project: sms-backup-plus-master  File: TestHelper.java View source code
public static String getResource(String name) throws IOException {
    final InputStream resourceAsStream = TestHelper.class.getResourceAsStream(name);
    assert (resourceAsStream != null);
    int n;
    byte[] buffer = new byte[8192];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    while ((n = resourceAsStream.read(buffer)) != -1) {
        bos.write(buffer, 0, n);
    }
    return new String(bos.toByteArray());
}
Example 62
Project: StaggeredGridViewDemo-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 63
Project: StudyGroupX-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 64
Project: t-board-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 65
Project: tawus-master  File: TestUtils.java View source code
public 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);
        }
        is.close();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return sb.toString();
}
Example 66
Project: TheRoll-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 67
Project: thread-local-dns-master  File: SampleFileLoader.java View source code
public static String loadAsUrl(String name) throws Exception {
    InputStream sample = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
    File temp = File.createTempFile("webdrivertest", name.replaceAll("/", "--"));
    FileUtils.copyInputStreamToFile(sample, temp);
    temp.deleteOnExit();
    return temp.getAbsolutePath();
}
Example 68
Project: trending-round-android-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 69
Project: v2droid-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 70
Project: WebAPI-master  File: ResourceHelper.java View source code
/**
     *
     * @param resource
     * @return
     */
public static String GetResourceAsString(String resource) {
    InputStream inputStream = ResourceHelper.class.getResourceAsStream(resource);
    String content = "";
    try {
        content = IOUtils.toString(inputStream, "UTF-8");
    } catch (Exception exception) {
        throw new RuntimeException("Resource not found: " + resource);
    }
    return content;
}
Example 71
Project: weclient-master  File: BitmapUtil.java View source code
public static Bitmap decodeBitmap(InputStream in) {
    Bitmap bitmap = null;
    try {
        bitmap = BitmapFactory.decodeStream(in);
    } catch (Exception e) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 2;
        bitmap = BitmapFactory.decodeStream(in, null, options);
    }
    return bitmap;
}
Example 72
Project: wifiserver-master  File: StringUtil.java View source code
public static String fromInputStream(InputStream inputStream) throws IOException {
    StringBuilder result = new StringBuilder();
    if (inputStream != null) {
        String line = null;
        BufferedReader reader = new BufferedReader(new InputStreamReader((inputStream)));
        while (null != (line = reader.readLine())) {
            result.append(line);
        }
    }
    return result.toString();
}
Example 73
Project: YikuairAndroid-master  File: HttpUtils.java View source code
public static InputStream getStreamFromURL(String imageURL) {
    InputStream in = null;
    try {
        URL url = new URL(imageURL);
        URLConnection openConnection = url.openConnection();
        if (openConnection != null && openConnection.getDate() > 0) {
            HttpURLConnection connection = (HttpURLConnection) openConnection;
            in = connection.getInputStream();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return in;
}
Example 74
Project: intellij-haxe-master  File: InputAdapter.java View source code
@Override
public java.lang.Object __hx_setField(java.lang.String field, java.lang.Object value, boolean handleProperties) {
    {
        boolean __temp_executeDef67 = true;
        switch(field.hashCode()) {
            case 107127:
                {
                    if (field.equals("mIs")) {
                        __temp_executeDef67 = false;
                        this.mIs = ((java.io.InputStream) (value));
                        return value;
                    }
                    break;
                }
        }
        if (__temp_executeDef67) {
            return super.__hx_setField(field, value, handleProperties);
        } else {
            throw null;
        }
    }
}
Example 75
Project: error-prone-master  File: InputStreamSlowMultibyteReadTest.java View source code
// Here, the superclass still can't effectively multibyte-read without the underlying
// read() method.
@Test
public void inherited() {
    compilationHelper.addSourceLines("Super.java", "abstract class Super extends java.io.InputStream {", "  public int read(byte[] b, int a, int c) { return 0; }", "}").addSourceLines("TestClass.java", "class TestClass extends Super {", "  byte[] buf = new byte[42];", "  // BUG: Diagnostic contains:", "  public int read() { return buf[0]; }", "}").doTest();
}
Example 76
Project: josm-plugins-master  File: CoderMixer2ST.java View source code
public int GetInStream(RecordVector<java.io.InputStream> inStreams, // const UInt64 **inSizes,
Object useless_inSizes, int streamIndex, java.io.InputStream[] inStreamRes) {
    java.io.InputStream seqInStream;
    int i;
    for (i = 0; i < _bindInfo.InStreams.size(); i++) if (_bindInfo.InStreams.get(i) == streamIndex) {
        seqInStream = inStreams.get(i);
        // seqInStream.Detach();
        inStreamRes[0] = seqInStream;
        return HRESULT.S_OK;
    }
    int binderIndex = _bindInfo.FindBinderForInStream(streamIndex);
    if (binderIndex < 0)
        return HRESULT.E_INVALIDARG;
    // TBD
    int tmp1[] = new int[1];
    // TBD
    int tmp2[] = new int[1];
    _bindInfo.FindOutStream(_bindInfo.BindPairs.get(binderIndex).OutIndex, tmp1, /* coderIndex */
    tmp2);
    int coderIndex = tmp1[0];
    CoderInfo coder = _coders.get(coderIndex);
    if (coder.Coder == null)
        return HRESULT.E_NOTIMPL;
    // coder.Coder.QueryInterface(IID_ISequentialInStream, &seqInStream);
    seqInStream = (java.io.InputStream) coder.Coder;
    if (seqInStream == null)
        return HRESULT.E_NOTIMPL;
    int startIndex = _bindInfo.GetCoderInStreamIndex(coderIndex);
    if (coder.Coder == null)
        return HRESULT.E_NOTIMPL;
    //  coder.Coder.QueryInterface(IID_ICompressSetInStream, &setInStream);
    ICompressSetInStream setInStream = (ICompressSetInStream) coder.Coder;
    if (setInStream == null)
        return HRESULT.E_NOTIMPL;
    if (coder.NumInStreams > 1)
        return HRESULT.E_NOTIMPL;
    for (i = 0; i < coder.NumInStreams; i++) {
        java.io.InputStream[] tmp = new java.io.InputStream[1];
        int res = GetInStream(inStreams, useless_inSizes, startIndex + i, tmp);
        if (res != HRESULT.S_OK)
            return res;
        java.io.InputStream seqInStream2 = tmp[0];
        res = setInStream.SetInStream(seqInStream2);
        if (res != HRESULT.S_OK)
            return res;
    }
    // seqInStream.Detach();
    inStreamRes[0] = seqInStream;
    return HRESULT.S_OK;
}
Example 77
Project: Link-ImageLoader-master  File: BaseImageDownloader.java View source code
@Override
public InputStream getStream(String imageUri, DisplayOptions extra) throws IOException {
    switch(Scheme.ofUri(imageUri)) {
        case HTTP:
        case HTTPS:
            return getStreamFromNetwork(imageUri, extra);
        case FILE:
            return getStreamFromFile(imageUri, extra);
        case CONTENT:
            return getStreamFromContent(imageUri, extra);
        case ASSETS:
            return getStreamFromAssets(imageUri, extra);
        case DRAWABLE:
            return getStreamFromDrawable(imageUri, extra);
        case UNKNOWN:
        default:
            return getStreamFromOtherSource(imageUri, extra);
    }
}
Example 78
Project: ameba-master  File: AbstractStreamingProcess.java View source code
/**
     * {@inheritDoc}
     */
@Override
public void write(T entity, OutputStream output, Long pos, Long length) throws IOException {
    InputStream in = getInputStream(entity);
    if (pos != null && pos > 0) {
        in.skip(pos);
    }
    if (length != null && length > 0) {
        in = ByteStreams.limit(in, length);
    }
    try {
        ReaderWriter.writeTo(in, output);
    } finally {
        IOUtils.closeQuietly(in);
    }
}
Example 79
Project: captivate-master  File: BitmapHelper.java View source code
protected Bitmap doInBackground(Void... empty) {
    try {
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        HttpResponse httpResponse = client.execute(httpGet);
        InputStream is = (java.io.InputStream) httpResponse.getEntity().getContent();
        return BitmapFactory.decodeStream(is);
    } catch (Exception e) {
    }
    return null;
}
Example 80
Project: disconnected-content-explorer-android-master  File: WebViewJavascriptBridgeClient.java View source code
private void loadWebViewJavascriptBridgeJs(WebView webView) {
    InputStream is = context.getResources().openRawResource(R.raw.webviewjavascriptbridge);
    String script = convertStreamToString(is);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(script, null);
    } else {
        webView.loadUrl("javascript:" + script);
    }
}
Example 81
Project: jsfs-master  File: BRequest_FileSystemService_readFile.java View source code
public void execute(BRemote __byps__remote, BAsyncResult<Object> __byps__asyncResult) throws Throwable {
    try {
        final FileSystemServiceAsync __byps__remoteT = (FileSystemServiceAsync) __byps__remote;
        BAsyncResultSendMethod<java.io.InputStream> __byps__outerResult = new BAsyncResultSendMethod<java.io.InputStream>(__byps__asyncResult, new BResult_15());
        __byps__remoteT.readFile(path, __byps__outerResult);
    } catch (Throwable e) {
        __byps__asyncResult.setAsyncResult(null, e);
    }
}
Example 82
Project: vnet-sms-master  File: EmbeddedClamshellLauncher.java View source code
/**
	 * @see vnet.sms.common.shell.clamshellspring.ClamshellLauncher#launch(java.io.InputStream,
	 *      java.io.OutputStream)
	 */
@Override
public void launch(final InputStream input, final OutputStream output) {
    this.log.info("Launching a new clamshell using input = {} and output = {} ...", input, output);
    this.context.putValue(Context.KEY_INPUT_STREAM, input);
    this.context.putValue(Context.KEY_OUTPUT_STREAM, output);
    this.context.getShell().plug(this.context);
    this.log.info("Clamshell has been terminated");
}
Example 83
Project: 3380-GAS-App-master  File: GetJsonTask.java View source code
protected String doInBackground(URL... urls) {
    InputStream dataStream;
    StringBuilder response = new StringBuilder();
    try {
        dataStream = urls[0].openStream();
        BufferedReader rd = new BufferedReader(new InputStreamReader(dataStream));
        int cp;
        while ((cp = rd.read()) != -1) {
            response.append((char) cp);
        }
        return response.toString();
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Example 84
Project: AcademicTorrents-Downloader-master  File: BEROctetStringParser.java View source code
public DERObject getDERObject() {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    InputStream in = this.getOctetStream();
    int ch;
    try {
        while ((ch = in.read()) >= 0) {
            bOut.write(ch);
        }
    } catch (IOException e) {
        throw new IllegalStateException("IOException converting stream to byte array: " + e.getMessage());
    }
    return new BERConstructedOctetString(bOut.toByteArray());
}
Example 85
Project: agui_eclipse_plugin-master  File: FileClassFinder.java View source code
public byte[] findClass(String name) {
    byte[] result = null;
    String className = basename + name.replace('.', '/') + ".class";
    File f = new File(className);
    if (f.exists()) {
        int len = (int) f.length();
        result = new byte[len];
        InputStream in;
        try {
            in = new FileInputStream(f);
            in.read(result);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return result;
}
Example 86
Project: AisenForAndroid-master  File: ContentProviderDownloader.java View source code
@Override
public byte[] downloadBitmap(Context context, String url, ImageConfig config) throws Exception {
    try {
        InputStream is = context.getContentResolver().openInputStream(Uri.parse(url));
        byte[] datas = FileUtils.readStreamToBytes(is);
        return datas;
    } catch (Exception e) {
        if (config.getProgress() != null)
            config.getProgress().downloadFailed(e);
        e.printStackTrace();
        throw e;
    }
}
Example 87
Project: Amigo-master  File: A.java View source code
public static String loadAsset(Context context) {
    try {
        InputStream is = context.getAssets().open("a.txt");
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        String line = reader.readLine();
        is.close();
        return line;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "Loading Error";
}
Example 88
Project: Android-Demo-Projects-master  File: MainActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mFaceOverlayView = (FaceOverlayView) findViewById(R.id.face_overlay);
    InputStream stream = getResources().openRawResource(R.raw.face);
    Bitmap bitmap = BitmapFactory.decodeStream(stream);
    mFaceOverlayView.setBitmap(bitmap);
}
Example 89
Project: android-google-spreadsheets-api-master  File: AssetsFileReader.java View source code
public String assetFileContents(final String fileName) throws IOException {
    StringBuilder text = new StringBuilder();
    InputStream fileStream = this.getClass().getClassLoader().getResourceAsStream("assets/" + fileName);
    BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream));
    String line;
    while ((line = reader.readLine()) != null) {
        text.append(line);
    }
    return text.toString();
}
Example 90
Project: android-ssl-master  File: IOUtil.java View source code
public static String readFully(InputStream inputStream) throws IOException {
    if (inputStream == null) {
        return "";
    }
    BufferedInputStream bufferedInputStream = null;
    ByteArrayOutputStream byteArrayOutputStream = null;
    try {
        bufferedInputStream = new BufferedInputStream(inputStream);
        byteArrayOutputStream = new ByteArrayOutputStream();
        final byte[] buffer = new byte[1024];
        int available = 0;
        while ((available = bufferedInputStream.read(buffer)) >= 0) {
            byteArrayOutputStream.write(buffer, 0, available);
        }
        return byteArrayOutputStream.toString();
    } finally {
        if (bufferedInputStream != null) {
            bufferedInputStream.close();
        }
    }
}
Example 91
Project: android-util-master  File: StreamUtils.java View source code
/**
     * @param inputStream inputStream
     * @return 字符串转�之�的
     */
public static String streamToString(InputStream inputStream) {
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        while ((len = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, len);
            out.flush();
        }
        String result = out.toString();
        out.close();
        inputStream.close();
        return result;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}
Example 92
Project: AndroidDemoProjects-master  File: MainActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mFaceOverlayView = (FaceOverlayView) findViewById(R.id.face_overlay);
    InputStream stream = getResources().openRawResource(R.raw.face);
    Bitmap bitmap = BitmapFactory.decodeStream(stream);
    mFaceOverlayView.setBitmap(bitmap);
}
Example 93
Project: AndroidProjectStroe-master  File: BitmapHelper.java View source code
public static Bitmap getBitmap(String imageUrl) {
    Bitmap mbBitmap = null;
    try {
        URL url = new URL(imageUrl);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        InputStream is = conn.getInputStream();
        mbBitmap = BitmapFactory.decodeStream(is);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return mbBitmap;
}
Example 94
Project: AndroidTutorialForBeginners-master  File: Operations.java View source code
// this method convert any stream to string
public static String ConvertInputToStringNoChange(InputStream inputStream) {
    BufferedReader bureader = new BufferedReader(new InputStreamReader(inputStream));
    String line;
    String linereultcal = "";
    try {
        while ((line = bureader.readLine()) != null) {
            linereultcal += line;
        }
        inputStream.close();
    } catch (Exception ex) {
    }
    return linereultcal;
}
Example 95
Project: androidutils-master  File: StreamUtils.java View source code
/**
     * @param inputStream inputStream
     * @return 字符串转�之�的
     */
public static String streamToString(InputStream inputStream) {
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        while ((len = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, len);
            out.flush();
        }
        String result = out.toString();
        out.close();
        inputStream.close();
        return result;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}
Example 96
Project: Android_Blog_Demos-master  File: LargeImageViewActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_large_image_view);
    mLargeImageView = (LargeImageView) findViewById(R.id.id_largetImageview);
    try {
        InputStream inputStream = getAssets().open("qm.jpg");
        mLargeImageView.setInputStream(inputStream);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 97
Project: android_ebook-master  File: CharsetDetector.java View source code
/**
	 * 检测当�文件的编�方�
	 */
public static Charset detect(InputStream in) {
    JChardetFacade detector = JChardetFacade.getInstance();
    Charset charset = null;
    try {
        in.mark(100);
        charset = detector.detectCodepage(in, 100);
        in.reset();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return charset;
}
Example 98
Project: ApprovalTests.Java-master  File: ApprovalXmlWriter.java View source code
private void format(String fileName) throws Exception {
    String text = "\"C:\\temp\\xmlstarlet-1.0.1\\xml.exe\" format \"%s\"";
    text = String.format(text, fileName);
    Process exec = Runtime.getRuntime().exec(text);
    InputStream stream = exec.getInputStream();
    Thread.sleep(400);
    FileUtils.redirectInputToFile(fileName, stream);
}
Example 99
Project: archive-commons-master  File: HttpResponseParser.java View source code
public HttpResponse parse(InputStream is) throws HttpParseException, IOException {
    HttpResponseMessage message = new HttpResponseMessage();
    HttpHeaders headers = new HttpHeaders();
    int headerBytes = messageParser.parse(is, message);
    headerBytes += headerParser.doParse(is, headers);
    HttpResponse response = new HttpResponse(is, message, headers);
    response.setHeaderBytes(headerBytes);
    // TODO: check for chunked transfer encoding
    return response;
}
Example 100
Project: Aspose_Words_Java-master  File: OpenDocUsingStream.java View source code
public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(OpenDocUsingStream.class);
    String filename = "Test.docx";
    InputStream in = new FileInputStream(dataDir + filename);
    Document doc = new Document(in);
    System.out.println("Document opened. Total pages are " + doc.getPageCount());
    in.close();
}
Example 101
Project: asura-j-master  File: PixmapTest.java View source code
public void testTMap() throws Exception {
    TMap ppm = new TMap();
    InputStream is = getClass().getClassLoader().getResourceAsStream("normal.tm2");
    ppm.read(is);
    is.close();
    byte[] tmap = ppm.getData();
    assertEquals(9, tmap[0]);
    assertEquals(9, tmap[1]);
    assertEquals(7, tmap[tmap.length - 2]);
    assertEquals(7, tmap[tmap.length - 1]);
}