javatips.net counter

Java Examples for java.io.InputStreamReader

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

Example 1
Project: betsy-master  File: GitUtil.java View source code
public static String getGitCommit() {
    Runtime rt = Runtime.getRuntime();
    try {
        Process pr = rt.exec("git rev-parse HEAD");
        try (BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()))) {
            String line = input.readLine();
            if (line.startsWith("fatal:")) {
                //no commit hash
                return "";
            } else {
                return line;
            }
        }
    } catch (IOException e) {
        return "";
    }
}
Example 2
Project: CodingSpectator-master  File: A_test460.java View source code
protected void extracted() throws InvocationTargetException {
    /*[*/
    InputStreamReader in = null;
    try {
        bar();
    } catch (IOException e) {
        throw new InvocationTargetException(null);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
            }
        }
    /*]*/
    }
}
Example 3
Project: dokuJClient-master  File: StdinReader.java View source code
public String readStdin() throws IOException {
    StringBuilder result = new StringBuilder();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String input;
    while ((input = br.readLine()) != null) {
        result.append(input + "\n");
    }
    if (result.length() > 0) {
        result.delete(result.length() - 1, result.length());
    }
    return result.toString();
}
Example 4
Project: eclipse.jdt.ui-master  File: A_test460.java View source code
protected void extracted() throws InvocationTargetException {
    /*[*/
    InputStreamReader in = null;
    try {
        bar();
    } catch (IOException e) {
        throw new InvocationTargetException(null);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
            }
        }
    /*]*/
    }
}
Example 5
Project: elasticsearch-oai-master  File: Runner.java View source code
public static void main(String[] args) {
    try {
        Class clazz = Class.forName(args[0]);
        CommandLineInterpreter commandLineInterpreter = (CommandLineInterpreter) clazz.newInstance();
        commandLineInterpreter.reader(new InputStreamReader(System.in, "UTF-8")).writer(new OutputStreamWriter(System.out, "UTF-8")).run();
    } catch (Throwable e) {
        e.printStackTrace();
        System.exit(1);
    }
    System.exit(0);
}
Example 6
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 7
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 8
Project: sandboxes-master  File: Docker.java View source code
public String dockerIp() {
    try {
        Process process = Runtime.getRuntime().exec("docker-machine ip docker-vm");
        process.waitFor();
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String ip = reader.readLine();
        reader.close();
        return ip;
    } catch (Exception e) {
        return "localhost";
    }
}
Example 9
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 10
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 11
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 12
Project: AlgoDS-master  File: ABProblem1000.java View source code
public static void main(String[] args) throws IOException {
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    String s = bufferedReader.readLine();
    int a = Integer.parseInt(s.split(" ")[0]);
    int b = Integer.parseInt(s.split(" ")[1]);
    PrintWriter writer = new PrintWriter(System.out);
    writer.write(a + b + "");
    writer.flush();
    writer.close();
}
Example 13
Project: Amigo-master  File: A.java View source code
public static String loadAsset(Context context) {
    try {
        // load the same entry
        //            InputStream is = context.getAssets().open("a.txt");
        // load new entry
        InputStream is = context.getAssets().open("b.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 14
Project: android-google-spreadsheets-api-master  File: WorksheetEntryRequest.java View source code
@Override
protected Response<WorksheetEntry> parseNetworkResponse(NetworkResponse response) {
    try {
        WorksheetEntry entry = parser.parseAndClose(new InputStreamReader(new ByteArrayInputStream(response.data)), WorksheetEntry.class);
        return Response.success(entry, HttpHeaderParser.parseCacheHeaders(response));
    } catch (IOException e) {
        return Response.error(new ParseError(e));
    }
}
Example 15
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 16
Project: asr-tsp-master  File: Test.java View source code
public static void main(String[] argv) {
    BufferedReader entree = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Entrez un message:");
    do {
        try {
            String tosend = entree.readLine();
        } catch (EOFException eof) {
            System.out.println("Test");
        } catch (IOException e) {
            e.printStackTrace();
        }
    } while (true);
}
Example 17
Project: BansheeCore-master  File: IOUtils.java View source code
public static String getStringFromStream(InputStream stream) throws IOException {
    StringBuilder builder = new StringBuilder();
    BufferedReader br = null;
    try {
        br = new BufferedReader(new InputStreamReader(stream));
        String temp;
        while ((temp = br.readLine()) != null) {
            builder.append(temp);
        }
    } finally {
        if (br != null)
            br.close();
    }
    return builder.toString();
}
Example 18
Project: c2g-master  File: BaseJsonTestCase.java View source code
public String readFile(String path) throws IOException {
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(path);
    BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
    String inputLine;
    StringBuilder data = new StringBuilder();
    while ((inputLine = in.readLine()) != null) {
        data.append(inputLine);
    }
    return data.toString();
}
Example 19
Project: Cardinal-Plus-master  File: MojangUtils.java View source code
public static String getNameByUUID(UUID uuid) {
    try {
        JSONObject response = (JSONObject) new JSONParser().parse(new InputStreamReader(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "")).openStream()));
        return (String) response.get("name");
    } catch (IOExceptionParseException |  e) {
        e.printStackTrace();
        return null;
    }
}
Example 20
Project: CardinalPGM-master  File: MojangUtil.java View source code
public static String getName(UUID uuid) {
    try {
        JSONObject response = (JSONObject) new JSONParser().parse(new InputStreamReader(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "")).openStream()));
        return (String) response.get("name");
    } catch (IOExceptionParseException |  e) {
        return null;
    }
}
Example 21
Project: CatHandsGendroid-master  File: ResourceUtil.java View source code
public static String getResourceAsString(String resourceName) throws IOException {
    InputStream in = null;
    try {
        in = ResourceUtil.class.getClassLoader().getResourceAsStream(resourceName);
        Reader reader = new InputStreamReader(in, "UTF-8");
        StringBuilder sb = new StringBuilder();
        char[] cbuf = new char[1 << 12];
        int r;
        while ((r = reader.read(cbuf)) > 0) {
            sb.append(cbuf, 0, r);
        }
        return sb.toString();
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e2) {
            }
        }
    }
}
Example 22
Project: claudia-master  File: DiskUtils.java View source code
public static String readFile(String path, String parentPath) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(parentPath, path))));
    StringBuffer ruleFile = new StringBuffer();
    String actualString;
    while ((actualString = reader.readLine()) != null) {
        ruleFile.append(actualString);
    }
    return ruleFile.toString();
}
Example 23
Project: clojure-maven-plugin-master  File: ResourceTest.java View source code
@Test
public void okJar() throws IOException {
    String bip = "/test/build-info.properties";
    InputStream s = getClass().getResourceAsStream(bip);
    Assert.assertNotNull(s);
    InputStreamReader sr = new InputStreamReader(s);
    BufferedReader bsr = new BufferedReader(sr);
    String line;
    try {
        while ((line = bsr.readLine()) != null) {
            System.out.println(line);
        }
    } finally {
        bsr.close();
    }
}
Example 24
Project: codeine-master  File: RequestBodyReader.java View source code
public String readBody(HttpServletRequest request) {
    if (body != null) {
        return body;
    }
    try {
        StringBuilder status = new StringBuilder();
        BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            status.append(inputLine);
        }
        in.close();
        body = status.toString();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return body;
}
Example 25
Project: CyanWool-master  File: ConsoleThread.java View source code
@Override
public void run() {
    // Console...
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while (running) {
        // Maybe...
        try {
            String line = reader.readLine();
            server.getCommandManager().dispatchCommand(server.getConsoleCommandSender(), line);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
Example 26
Project: Desktop-master  File: IOTools.java View source code
public static final String getStringFromStream(InputStream is, String charsetName) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(is, charsetName));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = br.readLine()) != null) {
        sb.append(line + System.getProperty("line.separator"));
    }
    br.close();
    return sb.toString();
}
Example 27
Project: detective-master  File: ServerRunner.java View source code
public static void main(String args[]) {
    try {
        Process p = Runtime.getRuntime().exec("java -jar /Users/bglcorp/git/detective/core/src/main/resources/seleniumserver/selenium-server-standalone-2.42.2.jar -timeout=20 -browserTimeout=60");
        p.waitFor();
        BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line = reader.readLine();
        while (line != null) {
            System.out.println(line);
            line = reader.readLine();
        }
    } catch (IOException e1) {
    } catch (InterruptedException e2) {
    }
    System.out.println("finished.");
}
Example 28
Project: Docear-master  File: IOTools.java View source code
public static final String getStringFromStream(InputStream is, String charsetName) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(is, charsetName));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = br.readLine()) != null) {
        sb.append(line + System.getProperty("line.separator"));
    }
    br.close();
    return sb.toString();
}
Example 29
Project: eclipse-commons-master  File: ProcessUtils.java View source code
/**
	 * Runs a process synchronously described by the given process builder and
	 * processes the lines of its output with the given output processor.
	 */
public static Process runProcess(ProcessBuilder processBuilder, OutputProcessor outputProcessor) throws IOException, InterruptedException {
    Process process = processBuilder.start();
    BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
    String line;
    while ((line = reader.readLine()) != null) {
        if (outputProcessor != null) {
            outputProcessor.processOutput(line);
        }
    }
    process.waitFor();
    return process;
}
Example 30
Project: hipi-master  File: ImageComparisonUtils.java View source code
public static boolean checkPsnr(String imgPath, String truthPath, float thresh) throws IOException {
    Runtime rt = Runtime.getRuntime();
    String cmd = "compare -metric PSNR " + imgPath + " " + truthPath + " /tmp/psnr.png";
    System.out.println(cmd);
    Process pr = rt.exec(cmd);
    Scanner scanner = new Scanner(new InputStreamReader(pr.getErrorStream()));
    float psnr = scanner.hasNextFloat() ? scanner.nextFloat() : 0;
    System.out.println("PSNR: " + psnr);
    //    assertTrue("PSNR is too low : " + psnr, psnr > 30);
    return (psnr >= thresh);
}
Example 31
Project: Java-AI-Book-Code-master  File: RunExternal.java View source code
public static void main(String argv[]) {
    try {
        String line;
        Process p = Runtime.getRuntime().exec("echo \"thhe dogg brked\" | /usr/local/bin/aspell  -a list");
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        while ((line = input.readLine()) != null) {
            System.out.println(line);
        }
        input.close();
    } catch (Exception err) {
        err.printStackTrace();
    }
}
Example 32
Project: javacuriosities-master  File: AppTest.java View source code
public void testPlusOperation() {
    try (InputStreamReader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("plusOperationTest.calc"))) {
        ExpressionLexer lexer = new ExpressionLexer(isr);
        CustomToken token = null;
        do {
            token = lexer.nextToken();
            if (token != null) {
                System.out.println(token);
            }
        } while (token != null);
        assertTrue(true);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 33
Project: javapassion-master  File: HundredNames3.java View source code
public static void main(String[] args) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String name = "";
    //gets the users' name
    try {
        System.out.print("Enter name: ");
        name = reader.readLine();
    } catch (Exception e) {
        System.out.println("Invalid input");
        System.exit(0);
    }
    //fore loop that prints the name one hundred times
    for (int counter = 0; counter < 100; counter++) {
        System.out.println(name);
    }
}
Example 34
Project: java_practical_semantic_web-master  File: RunExternal.java View source code
public static void main(String argv[]) {
    try {
        String line;
        Process p = Runtime.getRuntime().exec("echo \"thhe dogg brked\" | /usr/local/bin/aspell  -a list");
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        while ((line = input.readLine()) != null) {
            System.out.println(line);
        }
        input.close();
    } catch (Exception err) {
        err.printStackTrace();
    }
}
Example 35
Project: JD-Test-master  File: FillUtil.java View source code
/**
     * 按行读�文本文件
     *
     * @param is
     * @return
     * @throws Exception
     */
public static String readTextFromFile(InputStream is) throws Exception {
    InputStreamReader reader = new InputStreamReader(is);
    BufferedReader bufferedReader = new BufferedReader(reader);
    StringBuffer buffer = new StringBuffer("");
    String str;
    while ((str = bufferedReader.readLine()) != null) {
        buffer.append(str);
        buffer.append("\n");
    }
    return buffer.toString();
}
Example 36
Project: JFOA-master  File: Testclz.java View source code
/**
	 * @param args
	 */
public static void main(String[] args) {
    try {
        //		URL url=Testclz.class.getResource("/");
        //		System.out.println(url.toString());
        //		System.out.println(MD5.getMD5ofStr("123456").toLowerCase());
        Process p = Runtime.getRuntime().exec("ipconfig");
        BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), "GBK"));
        String s;
        while ((s = reader.readLine()) != null) {
            System.out.println(s);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 37
Project: jsf-test-master  File: URLRefBase.java View source code
protected String readInputStream(InputStream inputStream) throws IOException {
    StringBuilder content = new StringBuilder();
    // TODO - detect charset
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String inputLine;
    while ((inputLine = reader.readLine()) != null) {
        content.append(inputLine).append('\n');
    }
    reader.close();
    return content.toString();
}
Example 38
Project: justrelease-master  File: NPMProjectConfig.java View source code
@Override
public void readCurrentVersion() {
    JSONParser parser = new JSONParser();
    Object obj = null;
    try {
        obj = parser.parse(new InputStreamReader(projectConfigurationIS));
    } catch (Exception e) {
        e.printStackTrace();
    }
    JSONObject jsonObject = (JSONObject) obj;
    this.currentVersion = (String) jsonObject.get("version");
}
Example 39
Project: lmis-moz-mobile-master  File: JsonFileReader.java View source code
public static String readJson(Class clazz, String fileName) {
    InputStream in = clazz.getClassLoader().getResourceAsStream("data/" + fileName);
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuffer sb = new StringBuffer();
    try {
        String line = reader.readLine();
        while (line != null) {
            sb.append(line);
            line = reader.readLine();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return sb.toString();
}
Example 40
Project: marytts-master  File: StreamGobbler.java View source code
public void run() {
    try {
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        while ((line = br.readLine()) != null) System.out.println(type + ">" + line);
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
Example 41
Project: master-java-master  File: App.java View source code
public static void main(String[] args) throws IOException {
    //Console console = System.console();
    System.out.println("Introduzca una cadena:");
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader reader = new BufferedReader(isr);
    char[] list = reader.readLine().toCharArray();
    for (int i = list.length; i > 0; --i) System.out.print(list[i - 1]);
}
Example 42
Project: MCFreedomLauncher-master  File: FileBasedVersionList.java View source code
protected String getUrl(String uri) throws IOException {
    InputStream inputStream = getFileInputStream(uri);
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    StringBuilder result = new StringBuilder();
    String line;
    while ((line = reader.readLine()) != null) {
        if (result.length() > 0)
            result.append("\n");
        result.append(line);
    }
    reader.close();
    return result.toString();
}
Example 43
Project: MDE-Web-Service-Front-End-master  File: RegexTest.java View source code
public static void main(String[] args) {
    try {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(isr);
        while (true) {
            System.out.println("\n\nEnter equation (or CTRL-C to exit): ");
            String equation = reader.readLine();
            System.out.println(equation.matches(REGEX));
        }
    } catch (Exception e) {
        System.out.println("Oh noes.");
    }
}
Example 44
Project: Minecraft-Server-Mod-master  File: OThreadCommandReader.java View source code
@Override
public void run() {
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(System.in));
    String str = null;
    try {
        // hMod: Parse all console commands
        while ((!server.g) && ((str = localBufferedReader.readLine()) != null)) if (!etc.getInstance().parseConsoleCommand(str, server))
            server.a(str, server);
    } catch (IOException localIOException) {
        localIOException.printStackTrace();
    }
}
Example 45
Project: MoKitchen-master  File: DedicatedServerCommandThread.java View source code
public void run() {
    BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
    String s;
    try {
        while (!this.server.isServerStopped() && this.server.isServerRunning() && (s = bufferedreader.readLine()) != null) {
            this.server.addPendingCommand(s, this.server);
        }
    } catch (IOException ioexception) {
        ioexception.printStackTrace();
    }
}
Example 46
Project: mtgox-mini-bots-master  File: DefaultConsole.java View source code
public char[] readPassword(boolean echoInput) {
    try {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(isr);
        String result = in.readLine();
        in.close();
        isr.close();
        return result.toCharArray();
    } catch (IOException e) {
        throw new ParameterException(e);
    }
}
Example 47
Project: muJava-master  File: DefaultConsole.java View source code
public char[] readPassword(boolean echoInput) {
    try {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(isr);
        String result = in.readLine();
        in.close();
        isr.close();
        return result.toCharArray();
    } catch (IOException e) {
        throw new ParameterException(e);
    }
}
Example 48
Project: MyCC98-master  File: StreamUtils.java View source code
public static String Stream2String(InputStream stream) {
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "utf-8"));
        StringBuilder builder = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            builder.append(line);
        }
        return builder.toString();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
}
Example 49
Project: NanoPond-master  File: ResourcesLib.java View source code
public static CharSequence openRawTextFile(Resources resources, int id) throws IOException {
    StringBuilder result = new StringBuilder();
    try (InputStream ins = resources.openRawResource(id);
        BufferedReader reader = new BufferedReader(new InputStreamReader(ins))) {
        String line;
        while ((line = reader.readLine()) != null) {
            result.append(line + "\n");
        }
    }
    return result;
}
Example 50
Project: netty-cookbook-master  File: TCPServer.java View source code
public static void main(String argv[]) throws Exception {
    String clientSentence;
    String capitalizedSentence;
    ServerSocket welcomeSocket = new ServerSocket(6789);
    while (true) {
        Socket connectionSocket = welcomeSocket.accept();
        BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
        DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
        clientSentence = inFromClient.readLine();
        System.out.println("Received: " + clientSentence);
        capitalizedSentence = clientSentence.toUpperCase() + '\n';
        outToClient.writeBytes(capitalizedSentence);
    }
//welcomeSocket.close();
}
Example 51
Project: NewAndroidTwitter-master  File: StringUtil.java View source code
public static String streamToString(InputStream is) throws IOException {
    String str = "";
    if (is != null) {
        StringBuilder sb = new StringBuilder();
        String line;
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
            reader.close();
        } finally {
            is.close();
        }
        str = sb.toString();
    }
    return str;
}
Example 52
Project: News-Android-App-master  File: URLConnectionReader.java View source code
public static String getText(String url) throws Exception {
    URL website = new URL(url);
    URLConnection connection = website.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    StringBuilder response = new StringBuilder();
    String inputLine;
    while ((inputLine = in.readLine()) != null) response.append(inputLine);
    in.close();
    return response.toString();
}
Example 53
Project: newspaper-batch-event-framework-master  File: Utils.java View source code
/**
     * Utility method to read an inputstream to a hadoop text
     *
     * @param inputStream
     *
     * @return
     * @throws java.io.IOException
     */
public static Text asText(InputStream inputStream) throws IOException {
    StringBuilder builder = new StringBuilder();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String line;
    while ((line = reader.readLine()) != null) {
        builder.append(line);
    }
    reader.close();
    return new Text(builder.toString());
}
Example 54
Project: PalletTown-master  File: UrlUtil.java View source code
public static String openUrl(String address) {
    String response = "";
    URL url;
    try {
        url = new URL(address);
        try {
            URLConnection conn = url.openConnection();
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            response = br.readLine();
            //                System.out.println(response);
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return response == null ? "" : response;
}
Example 55
Project: paoding-master  File: ContentReader.java View source code
public static String readText(Class clazz) throws IOException {
    InputStream in = clazz.getResourceAsStream("text.txt");
    Reader re = new InputStreamReader(in, "UTF-8");
    char[] chs = new char[1024];
    int count;
    String content = "";
    while ((count = re.read(chs)) != -1) {
        content = content + new String(chs, 0, count);
    }
    return content;
}
Example 56
Project: pitest-master  File: FileUtil.java View source code
public static String readToString(final InputStream is) throws java.io.IOException {
    final StringBuilder fileData = new StringBuilder(1000);
    final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    char[] buf = new char[1024];
    int numRead = 0;
    while ((numRead = reader.read(buf)) != -1) {
        final String readData = String.valueOf(buf, 0, numRead);
        fileData.append(readData);
        buf = new char[1024];
    }
    reader.close();
    return fileData.toString();
}
Example 57
Project: platform_sdk-master  File: Lib2.java View source code
public static String getContent() {
    InputStream input = Lib2.class.getResourceAsStream("Lib2.txt");
    if (input == null) {
        return "FAILED TO FIND Lib2.txt";
    }
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
        return reader.readLine();
    } catch (IOException e) {
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }
    return "FAILED TO READ CONTENT";
}
Example 58
Project: plato-master  File: CharacterisationReportGeneratorTest.java View source code
@Test
public void testSimpleFITSReport() throws Exception {
    Reader simpleFits = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("fits/simple-fits.xml"), "UTF8");
    Reader fitsToHtml = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("fits/fits-to-html.xsl"), "UTF8");
    StringBuilder buffer = new StringBuilder();
    CharacterisationReportGenerator reportGen = new CharacterisationReportGenerator();
    reportGen.generateReportFromXML(simpleFits, fitsToHtml, new OutputStreamWriter(System.out));
}
Example 59
Project: PlotSquared-master  File: HttpUtil.java View source code
public static String readUrl(String urlString) {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(urlString).openStream()))) {
        StringBuilder buffer = new StringBuilder();
        int read;
        char[] chars = new char[1024];
        while ((read = reader.read(chars)) != -1) {
            buffer.append(chars, 0, read);
        }
        return buffer.toString();
    } catch (IOException e) {
        if (Settings.DEBUG) {
            e.printStackTrace();
        }
    }
    return null;
}
Example 60
Project: PocketMonstersOnline-master  File: StreamReader.java View source code
@Override
public void run() {
    try {
        InputStreamReader isr = new InputStreamReader(m_stream);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        while ((line = br.readLine()) != null) {
            System.out.println(m_streamName + ">" + line);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 61
Project: Priki-master  File: FileUtils.java View source code
public String readFile(String file) throws IOException {
    InputStream in = this.getClass().getResource(file).openStream();
    InputStreamReader inRead = new InputStreamReader(in);
    BufferedReader reader = new BufferedReader(inRead);
    StringBuilder builder = new StringBuilder();
    String temp;
    while ((temp = reader.readLine()) != null) {
        builder.append(temp);
    }
    reader.close();
    inRead.close();
    in.close();
    return builder.toString();
}
Example 62
Project: quickblox-android-sdk-master  File: AssetsUtils.java View source code
public static String getJsonAsString(String filename, Context context) throws IOException {
    AssetManager manager = context.getAssets();
    StringBuilder buf = new StringBuilder();
    InputStream json = manager.open(filename);
    BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
    String str;
    while ((str = in.readLine()) != null) {
        buf.append(str);
    }
    in.close();
    return buf.toString();
}
Example 63
Project: Rel-master  File: ClientConnection.java View source code
protected void obtainInitialServerResponse() throws IOException {
    initialServerResponse = new StringBuffer();
    String r;
    final BufferedReader input = new BufferedReader(new InputStreamReader(getServerResponseInputStream()));
    while ((r = input.readLine()) != null) {
        if (r.equals("<EOT>"))
            break;
        else if (!r.equals("Ok.")) {
            initialServerResponse.append(r);
            initialServerResponse.append('\n');
        }
    }
}
Example 64
Project: ruby-type-inference-master  File: SignatureClient.java View source code
public static void main(String[] args) throws IOException {
    String serverAddress = JOptionPane.showInputDialog("Enter IP Address of a machine that is\n" + "running the date service on port 9090:");
    Socket s = new Socket(serverAddress, 9090);
    BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream()));
    String answer = input.readLine();
    JOptionPane.showMessageDialog(null, answer);
    System.exit(0);
}
Example 65
Project: SAPJamSampleCode-master  File: JamNetworkResult.java View source code
public JSONObject toJson() throws IOException {
    JSONObject jsonResult = null;
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
    if (bufferedReader != null) {
        String resultStr = "";
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            resultStr += line;
        }
        bufferedReader.close();
        System.out.println("        JSON response: '" + resultStr + "'");
        jsonResult = new JSONObject(resultStr);
    }
    return jsonResult;
}
Example 66
Project: sneo-master  File: ConsoleBlocker.java View source code
public static void block(String message) {
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
    }
    BufferedReader r = null;
    try {
        r = new BufferedReader(new InputStreamReader(System.in));
        System.out.println(message);
        r.readLine();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (r != null) {
                r.close();
            }
        } catch (IOException e) {
        }
    }
}
Example 67
Project: Solr-Advert-master  File: BrandsLoader.java View source code
public static List<Brand> load(InputStream in) throws IOException {
    List<Brand> brands = new ArrayList<Brand>();
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    String line;
    while ((line = reader.readLine()) != null) {
        Brand brand = new Brand();
        brand.setName(line);
        brands.add(brand);
    }
    reader.close();
    return brands;
}
Example 68
Project: sparc-master  File: DefaultConsole.java View source code
public char[] readPassword(boolean echoInput) {
    try {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(isr);
        String result = in.readLine();
        in.close();
        isr.close();
        return result.toCharArray();
    } catch (IOException e) {
        throw new ParameterException(e);
    }
}
Example 69
Project: tc-ansible-runner-master  File: TestLogReader.java View source code
public static Playbook getPlaybook(String filename) {
    AnsibleOutputProcessor logProcessor = new AnsibleOutputProcessor();
    Playbook result = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(TestLogReader.class.getResourceAsStream(filename)))) {
        String strLine = "";
        while ((strLine = br.readLine()) != null) {
            logProcessor.onLine(strLine);
        }
        result = logProcessor.finish();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return result;
}
Example 70
Project: teiid-samples-master  File: FileFilterUtil.java View source code
public static void main(String[] args) throws IOException {
    File file = new File("time_log");
    FileInputStream fis = new FileInputStream(file);
    //Construct BufferedReader from InputStreamReader
    BufferedReader br = new BufferedReader(new InputStreamReader(fis));
    String line = null;
    while ((line = br.readLine()) != null) {
        if (line.startsWith("Deserialize")) {
            System.out.println(line);
        }
    }
    br.close();
}
Example 71
Project: terminatooor-master  File: OOORConsole.java View source code
public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    final ScriptEngine scriptEngine = manager.getEngineByName("jruby");
    InputStreamReader reader = new InputStreamReader(OOORConsole.class.getResourceAsStream("jirb_swing.rb"));
    try {
        scriptEngine.eval("CLOSE_OPERATION='exit'");
        scriptEngine.eval(reader);
    } catch (ScriptException ex) {
    }
}
Example 72
Project: testng_samples-master  File: DataProviders.java View source code
@DataProvider
public static Iterator<Object[]> loadUserFromFile() throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(DataProviders.class.getResourceAsStream("/user.data")));
    List<Object[]> userData = new ArrayList<Object[]>();
    String line = in.readLine();
    while (line != null) {
        userData.add(line.split(";"));
        line = in.readLine();
    }
    in.close();
    return userData.iterator();
}
Example 73
Project: TheMinecraft-master  File: DedicatedServerCommandThread.java View source code
public void run() {
    BufferedReader var1 = new BufferedReader(new InputStreamReader(System.in));
    String var2;
    try {
        while (!this.server.isServerStopped() && this.server.isServerRunning() && (var2 = var1.readLine()) != null) {
            this.server.addPendingCommand(var2, this.server);
        }
    } catch (IOException var4) {
        var4.printStackTrace();
    }
}
Example 74
Project: vesta-id-generator-master  File: VestaServer.java View source code
public static void main(String[] args) throws IOException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/vesta-server-main.xml");
    context.start();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    while (!"exit".equals(br.readLine())) try {
        Thread.sleep(60000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ;
}
Example 75
Project: zendserver-sdk-java-master  File: CSVLoader.java View source code
public String[][] load(InputStream in) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    List<String[]> result = new ArrayList<String[]>();
    String line;
    while ((line = br.readLine()) != null) {
        //$NON-NLS-1$
        result.add(line.split(","));
    }
    return result.toArray(new String[result.size()][]);
}
Example 76
Project: zh-solr-se-master  File: StreamConsumer.java View source code
public void run() {
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String line = null;
        while ((line = reader.readLine()) != null) {
            System.out.println(streamLabel + ">" + line);
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
Example 77
Project: abstools-master  File: StreamReaderThread.java View source code
public void run() {
    try {
        if (in != null) {
            writer = new StringWriter();
            InputStreamReader isr = new InputStreamReader(in);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            //Read the lines of the buffered reader.
            while ((line = br.readLine()) != null) writer.write(line + "\n");
            br.close();
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
Example 78
Project: AbstractViewAdapter-master  File: Templates.java View source code
public String read(String path) {
    InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream(path));
    BufferedReader bufferedReader = new BufferedReader(reader);
    StringBuilder builder = new StringBuilder();
    String line = null;
    do {
        try {
            if (line != null) {
                builder.append("\n");
            }
            line = bufferedReader.readLine();
            if (line != null) {
                builder.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
            break;
        }
    } while (line != null);
    return builder.toString();
}
Example 79
Project: Acernis-v144-master  File: LoadPacket.java View source code
public static byte[] getPacket() {
    Properties packetProps = new Properties();
    InputStreamReader is;
    try {
        is = new FileReader("CPacket.txt");
        packetProps.load(is);
        is.close();
    } catch (IOException ex) {
        System.out.println("Failed to load CPacket.txt");
    }
    MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.write(HexTool.getByteArrayFromHexString(packetProps.getProperty("packet")));
    return mplew.getPacket();
}
Example 80
Project: adastra-java-master  File: FileUtils.java View source code
public static List<String> readLines(String filename) {
    List<String> lines = new ArrayList<String>();
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader((FileUtils.class.getClassLoader().getResourceAsStream(filename))));
        try {
            String line = reader.readLine();
            while (line != null) {
                lines.add(line);
                line = reader.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            reader.close();
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return lines;
}
Example 81
Project: AIDR-master  File: MySpreadsheetIntegration.java View source code
public static void main(String[] args) throws Exception {
    String[] row = null;
    URL stockURL = new URL("http://localhost:8888/tornadotweets.csv");
    BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));
    CSVReader csvReader = new CSVReader(in);
    List content = csvReader.readAll();
    for (Object object : content) {
        row = (String[]) object;
        System.out.println(row[0] + " # " + row[1] + " #  " + row[2]);
    }
    csvReader.close();
}
Example 82
Project: AIM-master  File: Command.java View source code
@Override
public void run() {
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line = "";
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Example 83
Project: airship-master  File: RealInteractiveUser.java View source code
@Override
public boolean ask(String question, boolean defaultValue) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try {
        while (true) {
            System.out.print(question + (defaultValue ? " [Y/n] " : " [y/N] "));
            String line = null;
            try {
                line = reader.readLine();
            } catch (IOException ignored) {
            }
            if (line == null) {
                throw new IllegalArgumentException("Error reading from standard in");
            }
            line = line.trim().toLowerCase();
            if (line.isEmpty()) {
                return defaultValue;
            }
            if ("y".equalsIgnoreCase(line) || "yes".equalsIgnoreCase(line)) {
                return true;
            }
            if ("n".equalsIgnoreCase(line) || "no".equalsIgnoreCase(line)) {
                return false;
            }
        }
    } finally {
        System.out.println();
    }
}
Example 84
Project: Akka-Essentials-master  File: FileReadActor.java View source code
@Override
public void onReceive(Object message) throws Exception {
    if (message instanceof String) {
        String fileName = (String) message;
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource(fileName).openStream()));
            String line = null;
            while ((line = reader.readLine()) != null) {
                //System.out.println("File contents->" + line);
                getSender().tell(line);
            }
            System.out.println("All lines send !");
            // send the EOF message..
            getSender().tell(String.valueOf("EOF"));
        } catch (IOException x) {
            System.err.format("IOException: %s%n", x);
        }
    } else
        throw new IllegalArgumentException("Unknown message [" + message + "]");
}
Example 85
Project: alba-master  File: ALCmdLineReadThread.java View source code
/******************
     * 线程执行函数
     * 
     * @author alzq.z
     * @time   Feb 20, 2013 11:05:54 PM
     */
@Override
protected void _run() {
    //获�读�对象
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String cmd = null;
    while (true) {
        try {
            cmd = reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            continue;
        }
        //添加处�对象
        ALCmdDealerManager.getInstance().addCmd(cmd);
    }
}
Example 86
Project: android-calculatorpp-master  File: BaseIoLoader.java View source code
@Nullable
public CharSequence load() throws IOException {
    BufferedReader reader = null;
    try {
        final InputStream is = getInputStream();
        if (is == null) {
            return null;
        }
        reader = new BufferedReader(new InputStreamReader(is));
        final StringBuilder result = new StringBuilder();
        String line = reader.readLine();
        while (line != null) {
            result.append(line).append("\n");
            line = reader.readLine();
        }
        return result;
    } finally {
        Io.close(reader);
    }
}
Example 87
Project: android-gradle-plugin-master  File: LibApp.java View source code
private static String getContent() {
    InputStream input = LibApp.class.getResourceAsStream("Libapp.txt");
    if (input == null) {
        return "FAILED TO FIND Libapp.txt";
    }
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
        return reader.readLine();
    } catch (IOException e) {
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }
    return "FAILED TO READ CONTENT";
}
Example 88
Project: Android-PickerView-master  File: GetJsonDataUtil.java View source code
public String getJson(Context context, String fileName) {
    StringBuilder stringBuilder = new StringBuilder();
    try {
        AssetManager assetManager = context.getAssets();
        BufferedReader bf = new BufferedReader(new InputStreamReader(assetManager.open(fileName)));
        String line;
        while ((line = bf.readLine()) != null) {
            stringBuilder.append(line);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return stringBuilder.toString();
}
Example 89
Project: android-platform-tools-base-master  File: LibApp.java View source code
private static String getContent() {
    InputStream input = LibApp.class.getResourceAsStream("Libapp.txt");
    if (input == null) {
        return "FAILED TO FIND Libapp.txt";
    }
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
        return reader.readLine();
    } catch (IOException e) {
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }
    return "FAILED TO READ CONTENT";
}
Example 90
Project: android-reddit-master  File: StreamUtils.java View source code
public String convertStreamToString(InputStream is) throws UtilsException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    String line;
    StringBuilder sb = new StringBuilder();
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } catch (IOException e) {
        throw new UtilsException("Couldn't read line from stream.", e);
    } finally {
        try {
            if (is != null)
                is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}
Example 91
Project: android-youtube-listview-master  File: StreamUtils.java View source code
/**
     * A helper method to convert an InputStream into a String
     * @param inputStream
     * @return the String or a blank string if the IS was null
     * @throws IOException
     */
public static String convertToString(InputStream inputStream) throws IOException {
    if (inputStream != null) {
        Writer writer = new StringWriter();
        char[] buffer = new char[1024];
        try {
            Reader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 1024);
            int n;
            while ((n = reader.read(buffer)) != -1) {
                writer.write(buffer, 0, n);
            }
        } finally {
            inputStream.close();
        }
        return writer.toString();
    } else {
        return "";
    }
}
Example 92
Project: AndroidFileBroadcast-master  File: assetsOperation.java View source code
public static String htmlfile(String fname) {
    BufferedReader buff;
    String temp = "";
    StringBuilder sb = new StringBuilder();
    // =================================================== 
    AssetManager assetManager = ServerService.assetManager;
    // ===================================================
    Log.d("thisss", assetManager.toString() + "");
    InputStreamReader is_rd;
    try {
        is_rd = new InputStreamReader(assetManager.open(fname));
        buff = new BufferedReader(is_rd);
        while ((temp = buff.readLine()) != null) {
            sb.append(temp);
        }
    } catch (IOException e) {
        Log.d("message: ", e.getMessage());
    }
    Log.d("thisss", sb.toString());
    return sb.toString();
}
Example 93
Project: android_programlama_kitap-master  File: InternetTarayicisi.java View source code
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internettarayici);
    Intent intent = getIntent();
    TextView textView = (TextView) findViewById(R.id.internetIcerikView);
    Uri data = intent.getData();
    URL url;
    try {
        url = new URL(data.getScheme(), data.getHost(), data.getPath());
        BufferedReader rd = new BufferedReader(new InputStreamReader(url.openStream()));
        String line = "";
        while ((line = rd.readLine()) != null) {
            textView.append(line);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 94
Project: android_xcore-master  File: HttpDataSourceTest.java View source code
@Override
public String test() {
    try {
        InputStream inputStream = new HttpAndroidDataSource().getSource(new DataSourceRequest("http://yandex.ru"));
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 8192);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            sb.append(line).append(System.getProperty("line.separator"));
        }
        String value = sb.toString();
        inputStream.close();
        return value;
    } catch (IOException e) {
        return null;
    }
}
Example 95
Project: APKreatorWebsite-master  File: StreamUtils.java View source code
/**
     * A helper method to convert an InputStream into a String
     * @param inputStream
     * @return the String or a blank string if the IS was null
     * @throws IOException
     */
public static String convertToString(InputStream inputStream) throws IOException {
    if (inputStream != null) {
        Writer writer = new StringWriter();
        char[] buffer = new char[1024];
        try {
            Reader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 1024);
            int n;
            while ((n = reader.read(buffer)) != -1) {
                writer.write(buffer, 0, n);
            }
        } finally {
            inputStream.close();
        }
        return writer.toString();
    } else {
        return "";
    }
}
Example 96
Project: archive-commons-master  File: ZipNumBlockIterator.java View source code
public CloseableIterator<String> iterator() throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
    OpenJDK7GZIPInputStream gzis = new OpenJDK7GZIPInputStream(bais);
    InputStreamReader isr = new InputStreamReader(gzis);
    BufferedReader br = new BufferedReader(isr);
    return AbstractPeekableIterator.wrapReader(br);
}
Example 97
Project: autoparse-xml-master  File: XmlStreamReaderFactory.java View source code
public static XmlStreamReader newXmlStreamReader(InputStream in) throws ParseException {
    try {
        XmlPullParser pullParser = XmlPullParserFactory.newInstance().newPullParser();
        InputStreamReader inputStreamReader = new InputStreamReader(in);
        pullParser.setInput(inputStreamReader);
        return new XmlStreamReader(pullParser);
    } catch (XmlPullParserException e) {
        throw new ParseException(e);
    }
}
Example 98
Project: AwesomeLayoutManager-master  File: FakeDataProvider.java View source code
@Override
public List<Article> getArticles(int limit) {
    Gson gson = new Gson();
    Article[] articles = gson.fromJson(new InputStreamReader(context.getResources().openRawResource(R.raw.data)), Article[].class);
    ArrayList<Article> list = new ArrayList<>();
    int max = limit == 0 ? articles.length * 5 : Math.min(articles.length * 5, limit);
    for (int i = 0; i < max; i++) {
        list.add(articles[i % articles.length]);
    }
    return list;
}
Example 99
Project: behave-master  File: StreamGobbler.java View source code
public void run() {
    try {
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            outputLine += line;
        }
    } catch (IOException ioException) {
        ioException.printStackTrace();
    }
}
Example 100
Project: Benchit-master  File: LogCat.java View source code
@Override
public void run() {
    try {
        Runtime.getRuntime().exec("logcat -c ");
        Process process = Runtime.getRuntime().exec("logcat -s " + Benchit.TAG);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            String[] sections = line.split(":");
            if (sections.length > 1) {
                Message msg = Message.obtain();
                msg.obj = sections[1];
                mHandler.sendMessage(msg);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 101
Project: BGAWeiBo-Android-master  File: AssetsUtils.java View source code
public static String getString(String fileName) {
    if (TextUtils.isEmpty(fileName)) {
        return null;
    }
    StringBuilder sb = new StringBuilder("");
    try {
        InputStreamReader in = new InputStreamReader(App.getInstance().getAssets().open(fileName));
        BufferedReader br = new BufferedReader(in);
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        return sb.toString();
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}