Package java.io

Examples of java.io.BufferedInputStream.available()


            try
            {
                fis = new FileInputStream(file);
                BufferedInputStream bis = new BufferedInputStream(fis);
                int bytes = bis.available();
                byte[] raw = new byte[bytes];

                bis.read(raw);
                content = new String(raw, "UTF-8");
                content = content.replaceAll("\r\n","\n");
View Full Code Here


    }
    BufferedInputStream bufferedInputStream = new BufferedInputStream(
        f.getContents());
    ByteArrayOutputStream stream = new ByteArrayOutputStream((int) 10000);
    try {
      while (bufferedInputStream.available() >= 0) {
        int k = bufferedInputStream.read();
        if (k == -1) {
          break;
        } else {
          stream.write(k);
View Full Code Here

          InputStream contents = new BufferedInputStream(fl
              .getContents(true));

          try {

            while (contents.available() >= 0) {
              int read = contents.read();
              if (read != -1) {
                b.write(read);

              } else {
View Full Code Here

        if (open != null) {
          try {
            FileInputStream fs = new FileInputStream(open);
            BufferedInputStream bs = new BufferedInputStream(fs);
            ByteArrayOutputStream s = new ByteArrayOutputStream();
            while (bs.available() >= 0) {
              int k = bs.read();
              if (k == -1) {
                break;
              }
              s.write(k);
View Full Code Here

  private byte[] getBytesFromStream(InputStream stream) {
    if (stream == null)
      return null;
    BufferedInputStream bis = new BufferedInputStream(stream);
    try {
      int size = (int) bis.available();
      byte[] b = new byte[size];
      int rb = 0;
      int chunk = 0;

      while (((int) size - rb) > 0) {
View Full Code Here

//    if(filename==null || filename.equals(""))
//    {
//      throw new NullPointerException("��Ч���ļ�·��");
//    }
    BufferedInputStream bufferedInputStream=new BufferedInputStream(Util.class.getResourceAsStream("DES.properties"));
    long len = bufferedInputStream.available();
    byte[] bytes = new byte[(int)len];

    int r = bufferedInputStream.read( bytes );
    if (r != len)
      throw new IOException("��ȡ�ļ�����ȷ");
View Full Code Here

   * @throws IOException
   * @return byte[]
   */
  public byte[] readFileJar(String filename) throws IOException {
    BufferedInputStream bufferedInputStream=new BufferedInputStream(getClass().getResource(filename).openStream());
    int len=bufferedInputStream.available();
    byte[] bytes=new byte[len];
    int r=bufferedInputStream.read(bytes);
    if(len!=r)
    {
      bytes=null;
View Full Code Here

      Process process = Runtime.getRuntime().exec(command);
     
      // check error stream
      BufferedInputStream errorStream = new BufferedInputStream(process.getErrorStream());
      if (errorStream.available() > 0) {
        BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream));
        while ((line = errorReader.readLine()) != null) {
          System.out.println(line);
          error = true;
        }
View Full Code Here

        // Test that a closed stream throws an IOE for available()
        BufferedInputStream bis = new BufferedInputStream(
                new ByteArrayInputStream(new byte[] { 'h', 'e', 'l', 'l', 'o',
                        ' ', 't', 'i', 'm' }));
        int available = bis.available();
        bis.close();
        assertTrue(available != 0);

        try {
            bis.available();
View Full Code Here

        int available = bis.available();
        bis.close();
        assertTrue(available != 0);

        try {
            bis.available();
            fail("Expected test to throw IOE.");
        } catch (IOException ex) {
            // expected
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.