发送文件

@param ins
@param size
@param ous
@throws IOException
1573
protected void sendFileContent(InputStream ins, long size, OutputStream ous) throws IOException {
        LOGGER.debug("开始上传文件流大小为{}", size);
        long remainBytes = size;
        byte[] buff = new byte[256 * 1024];
        int bytes;
        while (remainBytes > 0) {
            if ((bytes = ins.read(buff, 0, remainBytes > buff.length ? buff.length : (int) remainBytes)) < 0) {
                throw new IOException("the end of the stream has been reached. not match the expected size ");
            }

            ous.write(buff, 0, bytes);
            remainBytes -= bytes;
            LOGGER.debug("剩余数据量{}", remainBytes);
        }
    }
937326
public static final void setSize(UIObject o, Rect size) {
        o.setPixelSize(size.w, size.h);

    }
581655
public static void splitBySize(final File file, final long sizeOfPart, final File destDir) throws UncheckedIOException {
        final int numOfParts = (int) ((file.length() % sizeOfPart) == 0 ? (file.length() / sizeOfPart) : (file.length() / sizeOfPart) + 1);

        final String fileName = file.getName();
        final long fileLength = file.length();
        int fileSerNum = 1;

        final byte[] buf = Objectory.createByteArrayBuffer();
        InputStream input = null;
        OutputStream output = null;
        try {
            input = new FileInputStream(file);

            for (int i = 0; i < numOfParts; i++) {
                String subFileNmae = destDir.getAbsolutePath() + IOUtil.FILE_SEPARATOR + fileName + "_" + StringUtil.padStart(N.stringOf(fileSerNum++), 4, '0');
                output = new FileOutputStream(new File(subFileNmae));
                long partLength = sizeOfPart;

                if (i == numOfParts - 1) {
                    partLength += fileLength % numOfParts;
                }

                int count = 0;

                try {
                    while (partLength > 0 && EOF != (count = read(input, buf, 0, (int) Math.min(buf.length, partLength)))) {
                        output.write(buf, 0, count);

                        partLength = partLength - count;
                    }

                    output.flush();
                } finally {
                    close(output);
                }
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        } finally {
            Objectory.recycle(buf);

            closeQuietly(input);
        }
    }
815545
protected IntBuffer createIntBuffer(int size) {
      ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
      temp.order(ByteOrder.nativeOrder());

      return temp.asIntBuffer();
    }
664180
public void insert(final InsnList insns) {
        if (insns.size == 0) {
            return;
        }
        size += insns.size;
        if (first == null) {
            first = insns.first;
            last = insns.last;
        } else {
            AbstractInsnNode elem = insns.last;
            first.prev = elem;
            elem.next = first;
            first = insns.first;
        }
        cache = null;
        insns.removeAll(false);
    }
1117111
public void init(WriteStream os)
  {
    _os = os;
    _openCount.set(1);
    
    switch (_peer) {
    case CLIENT:
      _nextStreamId = 1;
      break;
      
    case SERVER:
      _nextStreamId = 2;
      break;
      
    default:
      throw new IllegalStateException(String.valueOf(_peer));
    }

    if (_conn.isHeaderHuffman()) {
      _outHeader = new OutHeaderHuffman(os);
    }
    else {
      _outHeader = new OutHeader(os);
    }
  }
429828
private void validateBlockSize(byte[] descriptor) throws IOException {
        int blockSize = Util.getUInt16Both(descriptor, 129);
        if (blockSize != Constants.DEFAULT_BLOCK_SIZE) {
            throw new LoopFileSystemException("Invalid block size: " + blockSize);
        }
    }
151501
private void initFileSystem() throws IOException {
		if (fs == null) {
			Path path = new Path(basePath);
			fs = createHadoopFileSystem(path, fsConfig);
		}
	}
421439
public static void copyStream(InputStream is, OutputStream os) throws IOException {
        copyStream(is, os, DEFAULT_BUFFER_SIZE);
    }
915986
private static void copyStream(InputStream is, OutputStream os, int bufferSize)
            throws IOException {
        Assert.checkNotNullParam("is", is);
        Assert.checkNotNullParam("os", os);
        byte[] buff = new byte[bufferSize];
        int rc;
        while ((rc = is.read(buff)) != -1) os.write(buff, 0, rc);
        os.flush();
    }
1067206
public final void fiadd(Mem src)
  {
    assert(src.size() == 2 || src.size() == 4);
    emitX86(INST_FIADD, src);
  }
218901
static public void copyStream(InputStream is, OutputStream os, int transferBufferSize) throws IOException {
		if( transferBufferSize < 1 ) {
			throw new IOException("Transfer buffer size can not be smaller than 1");
		}

		byte[] buffer = new byte[transferBufferSize];

		int bytesRead = is.read(buffer);
		while( bytesRead >= 0 ) {
			os.write(buffer, 0, bytesRead);

			bytesRead = is.read(buffer);
		}
	}
93225
def IOR(type, nr, size):
    
    return IOC(IOC_READ, type, nr, IOC_TYPECHECK(size))
438992
public static void copyStreamSafely( InputStream in, ByteArrayOutputStream os ) throws IOException {

		try {
			copyStreamUnsafelyUseWithCaution( in, os );

		} finally {
			in.close();
		}
	}
1057115
public static byte[] recv(InputStream in, int size) throws IOException {
		byte [] bytes = new byte [size];
		int numRead = in.read(bytes);
		if(numRead==-1) {
			throw new IOException("premature end of data");
		}
		while (numRead < size) {
		  int len = in.read(bytes, numRead, size - numRead);
		  if(len==-1) {
			  throw new IOException("premature end of data");
		  }
		  numRead+=len;
		}
		return bytes;
	}
526738
long getPreferredBlockSize(String filename) throws IOException {
    byte[][] components = INodeDirectory.getPathComponents(filename);
    readLock();
    try {
      INode fileNode = rootDir.getNode(components);
      if (fileNode == null) {
        throw new IOException("Unknown file: " + filename);
      }
      if (fileNode.isDirectory()) {
        throw new IOException("Getting block size of a directory: " +
                              filename);
      }
      return ((INodeFile)fileNode).getPreferredBlockSize();
    } finally {
      readUnlock();
    }
  }
423241
public void copy(File in, File out) throws IOException {
	InputStream is = null;
	OutputStream os = null;
	try {
	    is = new BufferedFileInputStream(in);
	    os = new BufferedFileOutputStream(out);
	}
	catch (IOException ioe) {
	    closeEL(is, os);
	    throw ioe;
	}
	copy(is, os, true, true);
    }