Package com.netfever.web.storage.datasources

Source Code of com.netfever.web.storage.datasources.LocalWebStream

package com.netfever.web.storage.datasources;

import java.io.File;
import java.io.FileInputStream;
import java.nio.channels.FileChannel;

import com.netfever.web.storage.api.IWebStream;
import com.netfever.web.storage.api.StorageException;

public class LocalWebStream implements IWebStream {
  private String mime;
  private File file;
 
  public LocalWebStream(String mime, File file) {
    super();
   
    this.mime = mime;
    this.file = file;
  }
 
  @Override
  public String getMime() {
    return this.mime;
  }

  @Override
  public FileChannel openChannel() throws StorageException {
    try {
      return new FileInputStream(this.file).getChannel();
    } catch (Exception e) {
      throw new StorageException(e.getMessage(), e);
    }
  }

  @Override
  public int getLength() {
    return (int)this.file.length();
  }
}
TOP

Related Classes of com.netfever.web.storage.datasources.LocalWebStream

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.