Ali MaxCompute SDK

ALI MC 文件读写
    public abstract BufferedInputStream readResourceFileAsStream(String var1) throws IOException;

LocalExecutionContext.java

  @Override
  public BufferedInputStream readResourceFileAsStream(String resourceName) throws IOException {
    try {
      return wareHouse.readResourceFileAsStream(wareHouse.getOdps().getDefaultProject(),
                                                resourceName, ',');
    } catch (OdpsException e) {
      throw new IOException(e.getMessage());
    }

  }

WareHouse.java

  public BufferedInputStream readResourceFileAsStream(String project, String resource,
                                                      char inputColumnSeperator)
      throws IOException, OdpsException {

    if (!existsResource(project, resource)) {
      DownloadUtils.downloadResource(WareHouse.getInstance().getOdps(), getOdps()
          .getDefaultProject(), resource, getLimitDownloadRecordCount(), inputColumnSeperator);
    }

    if (!existsResource(project, resource)) {
      throw new OdpsException("File Resource " + project + "." + resource + " not exists");
    }

    File file = getReourceFile(project, resource);
    if (!file.isFile()) {
      throw new OdpsException("Resource " + project + "." + resource
                              + " is not a valid file Resource, because it is a direcotry");
    }
    return new BufferedInputStream(new FileInputStream(file));
  }

JDK BufferedInputStream
/**
 * A BufferedInputStream adds
 * functionality to another input stream-namely,
 * the ability to buffer the input and to
 * support the mark and reset
 * methods. When  the BufferedInputStream
 * is created, an internal buffer array is
 * created. As bytes  from the stream are read
 * or skipped, the internal buffer is refilled
 * as necessary  from the contained input stream,
 * many bytes at a time. The mark
 * operation  remembers a point in the input
 * stream and the reset operation
 * causes all the  bytes read since the most
 * recent mark operation to be
 * reread before new bytes are  taken from
 * the contained input stream.
 *
 * @author  Arthur van Hoff
 * @since   JDK1.0
 */
public
class BufferedInputStream extends FilterInputStream {

    private static int DEFAULT_BUFFER_SIZE = 8192;

你可能感兴趣的:(odps,java,大数据)