@Override
 public void close() throws IOException {
   super.close();
   buf = null;
   head = pos = tail = 0;
   mark = -1;
 }
 @Override
 public void reset() {
   try {
     super.reset();
   } catch (IOException e) {
     // ignore
   }
 }
 @Override
 public void close() throws IOException {
   try {
     super.close();
   } finally {
     entity.consumeContent();
   }
 }
 @Override
 public final synchronized void close() throws IOException {
   try {
     super.close();
   } catch (final OutOfMemoryError e) {
     ConcurrentLog.logException(e);
   }
   this.finish();
 }
Пример #5
0
 /**
  * Closes this input stream and releases any system resources associated with the stream.
  *
  * @exception java.io.IOException If an error occurs closing the file.
  */
 public synchronized void close() throws IOException {
   if (reliable != null) {
     try {
       super.close();
     } finally {
       reliable.closeInputFile();
       reliable = null;
     }
   }
 }
Пример #6
0
 @Override
 public void close() throws IOException {
   try {
     super.close();
   } finally {
     try {
       zipFile.close();
     } catch (IOException e2) {
       LOG.debug("Could not close the zip file");
     }
   }
 }
 @Override
 public void close() throws IOException {
   if (!closed) {
     try {
       copy(this, new NullOutputStream());
     } catch (IOException e) {
     } finally {
       closed = true;
       super.close();
     }
   }
 }
Пример #8
0
    @Override
    public void close() throws IOException {
      if (tmp_out != null) {
        Utils.closeQuietly(tmp_out);
        tmp_out = null;

        // Rename the file to the permanent name
        if (!errord) {
          File newtmpfile = new File(cachedir, urlToCacheFilename(url));
          errord = !tmpfile.renameTo(newtmpfile);
          if (!errord) {
            tmpfile = newtmpfile;
          }
        }

        // Add to cache
        if (errord) {
          tmpfile.delete();
        } else {
          synchronized (ImageCache.this) {
            Log.d(TAG, "adding " + url);
            filecachelist.add(tmpfile);
            filecachemap.put(url, tmpfile);
            filecachesize += tmpfile.length();
            // Trim cache
            while (filecachesize > MAX_FILECACHE_SIZE) {
              File trimfile = filecachelist.remove(0); // oldest
              Log.d(TAG, "trimming " + trimfile.getName());
              filecachemap.remove(trimfile.getName());
              filecachesize -= trimfile.length();
              trimfile.delete();
            }
          }
        }
      }
      super.close();
    }
 /**
  * Marks the current position in this input stream. A subsequent call to the reset method
  * repositions this stream at the last marked position so that subsequent reads re-read the same
  * bytes.
  *
  * <p>The readlimit arguments tells this input stream to allow that many bytes to be read before
  * the mark position gets invalidated.
  *
  * <p>The number of bytes read from this stream at this instance is noted so that on subsequent
  * calls to reset, the bytesRead can be reset to this value if mark is success.
  */
 @Override
 public synchronized void mark(int readlimit) {
   super.mark(readlimit);
   mark = bytesRead;
 }
 @Override
 public void close() throws IOException {
   super.close();
   inputStreamClosed = true;
 }
Пример #11
0
 @Override
 public void close() throws IOException {
   super.close();
   out.close();
 }
Пример #12
0
 /* (non-Javadoc)
  * @see java.io.FilterInputStream#close()
  */
 @Override
 public void close() throws IOException {
   System.out.println();
   System.out.flush();
   super.close();
 }
 public void reset() throws IOException {
   super.reset();
   _uploadState.fileProgressed(_markedPosition);
 }
 public void mark(int readlimit) {
   super.mark(readlimit);
   _markedPosition = _uploadState.getFileBytesSent();
 }
Пример #15
0
 public synchronized void reset() throws IOException {
   super.reset();
   md.reset();
 }
Пример #16
0
 /**
  * Closes this input stream and releases any system resources associated with the stream. This
  * method simply performs <code>in.close()</code>.
  *
  * @exception IOException if an I/O error occurs.
  * @see java.io.FilterInputStream#in
  */
 @Override
 public void close() throws IOException {
   closed = true;
   super.close();
 }
 @Override
 public void mark(int readlimit) {
   super.mark(readlimit);
   availableBytes = readlimit;
 }
Пример #18
0
  public static void main(String argv[]) {
    if (argv.length < 4) {
      System.out.println("usage: java Modbus dns_name unit reg_no num_regs");
      System.out.println("eg java Modbus aswales8.modicon.com 5 0 10");
      return;
    }
    try {
      String ip_adrs = argv[0];
      int unit = Integer.parseInt(argv[1]);
      int reg_no = Integer.parseInt(argv[2]);
      int num_regs = Integer.parseInt(argv[3]);
      System.out.println(
          "ip_adrs = "
              + ip_adrs
              + " unit = "
              + unit
              + " reg_no = "
              + reg_no
              + " num_regs = "
              + num_regs);

      // set up socket
      Socket es = new Socket(ip_adrs, 502);
      OutputStream os = es.getOutputStream();
      FilterInputStream is = new BufferedInputStream(es.getInputStream());
      byte obuf[] = new byte[261];
      byte ibuf[] = new byte[261];
      int c = 0;
      int i;

      // build request of form 0 0 0 0 0 6 ui 3 rr rr nn nn
      for (i = 0; i < 5; i++) obuf[i] = 0;
      obuf[5] = 6;
      obuf[6] = (byte) unit;
      obuf[7] = 3;
      obuf[8] = (byte) (reg_no >> 8);
      obuf[9] = (byte) (reg_no & 0xff);
      obuf[10] = (byte) (num_regs >> 8);
      obuf[11] = (byte) (num_regs & 0xff);

      // send request
      os.write(obuf, 0, 12);

      // read response
      i = is.read(ibuf, 0, 261);
      if (i < 9) {
        if (i == 0) {
          System.out.println("unexpected close of connection at remote end");
        } else {
          System.out.println("response was too short - " + i + " chars");
        }
      } else if (0 != (ibuf[7] & 0x80)) {
        System.out.println("MODBUS exception response - type " + ibuf[8]);
      } else if (i != (9 + 2 * num_regs)) {
        System.out.println("incorrect response size is " + i + " expected" + (9 + 2 * num_regs));
      } else {
        for (i = 0; i < num_regs; i++) {
          int w = (ibuf[9 + i + i] << 8) + (ibuf[10 + i + i] & 0x00FF);
          System.out.println("word " + i + " = " + w);
        }
      }

      // close down
      es.close();
    } catch (Exception e) {
      System.out.println("exception :" + e);
    }
  }
 @Override
 public void close() throws IOException {
   super.close();
   mFile.delete();
 }
 @Override
 protected void finalize() throws Throwable {
   close();
   super.finalize();
 }
 /**
  * Repositions this stream to the position at the time the mark method was last called on this
  * input stream if and only if mark is supported by the input stream.
  *
  * <p>Resets the bytesRead parameter to the mark value.
  */
 @Override
 public synchronized void reset() throws IOException {
   super.reset();
   if (super.markSupported()) bytesRead = mark;
 }
Пример #22
0
 @Override
 public void close() throws IOException {
   Log.d(tag, log.toString() + (overflow ? "…" : ""));
   super.close();
 }
 @Override
 public void close() throws IOException {
   super.close();
   flushLog();
 }
Пример #24
0
 /**
  * * Closes the stream and immediately afterward closes the referenced socket.
  *
  * <p>
  *
  * @exception IOException If there is an error in closing the stream or socket. *
  */
 public void close() throws IOException {
   super.close();
   __socket.close();
 }
 @Override
 public void close() throws IOException {
   super.close();
   alternate.close();
 }
 @Override
 public void reset() throws IOException {
   super.reset();
   availableBytes = UNSET;
 }
Пример #27
0
 @Override
 public void close() throws IOException {
   super.close();
   if (sftp != null) sftp.disconnect();
 }