There are 6 code examples for java.io.BufferedOutputStream.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: jFreeChart Package: org.jfree.chart.servlet

Source Code: ServletUtilities.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Binary streams the specified file to the HTTP response in 1KB chunks.
 * @param file  the file to be streamed.
 * @param response  the HTTP response object.
 * @param mimeType  the mime type of the file, null allowed.
 * @throws IOException if there is an I/O problem.
 */
public static void sendTempFile(File file,HttpServletResponse response,String mimeType) throws IOException {
  if (file.exists()) {
    BufferedInputStream bis=new BufferedInputStream(new FileInputStream(file));
    if (mimeType != null) {
      response.setHeader("Content-Type",mimeType);
    }
    response.setHeader("Content-Length",String.valueOf(file.length()));
    SimpleDateFormat sdf=new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",Locale.ENGLISH);
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
    response.setHeader("Last-Modified",sdf.format(new Date(file.lastModified())));
    BufferedOutputStream bos=new BufferedOutputStream(response.getOutputStream());
    byte[] input=new byte[1024];
    boolean eof=false;
    while (!eof) {
      int length=bis.read(input);
      if (length == -1) {
        eof=true;
      }
 else {
        bos.write(input,0,length);
      }
    }
    bos.flush();
    bis.close();
    bos.close();
  }
 else {
    throw new FileNotFoundException(file.getAbsolutePath());
  }
  return;
}
 

Project Name: rssowl.ui Package: org.rssowl.ui.internal

Source Code: ApplicationServer.java (Click to view .java file)

Method Code:
vote
like

private void processResourceOperation(Socket socket,String message){
  int start=message.indexOf(OP_RESOURCE) + OP_RESOURCE.length();
  int end=message.indexOf(' ',start);
  String parameter=message.substring(start,end);
  BufferedOutputStream outS=null;
  try {
    outS=new BufferedOutputStream(socket.getOutputStream());
    CoreUtils.copy(OwlUI.class.getResourceAsStream(parameter),outS);
  }
 catch (  IOException e) {
  }
 finally {
    if (outS != null) {
      try {
        outS.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
 

Project Name: weka Package: weka.core

Source Code: WekaPackageManager.java (Click to view .java file)

Method Code:
vote
like

public static Exception refreshCache(PrintStream... progress){
  Exception problem=null;
  if (CACHE_URL == null) {
    return null;
  }
  PACKAGE_MANAGER.setPackageRepositoryURL(REP_URL);
  String cacheDir=WEKA_HOME.toString() + File.separator + "repCache";
  try {
    for (    PrintStream p : progress) {
      p.println("Refresh in progress. Please wait...");
    }
    byte[] zip=PACKAGE_MANAGER.getRepositoryPackageMetaDataOnlyAsZip(progress);
    ZipInputStream zis=new ZipInputStream(new ByteArrayInputStream(zip));
    ZipEntry ze;
    final byte[] buff=new byte[1024];
    while ((ze=zis.getNextEntry()) != null) {
      if (ze.isDirectory()) {
        new File(cacheDir,ze.getName()).mkdir();
        continue;
      }
      BufferedOutputStream bo=new BufferedOutputStream(new FileOutputStream(new File(cacheDir,ze.getName())));
      while (true) {
        int amountRead=zis.read(buff);
        if (amountRead == -1) {
          break;
        }
        bo.write(buff,0,amountRead);
      }
      bo.close();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    CACHE_URL=null;
    try {
      DefaultPackageManager.deleteDir(new File(cacheDir),System.out);
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
    return e;
  }
  return problem;
}
 

Project Name: weka Package: weka.gui

Source Code: SimpleCLIPanel.java (Click to view .java file)

Method Code:
vote
like

/** 
 * saves the current command history in the user's home directory.
 */
protected void saveHistory(){
  int size;
  int from;
  int i;
  String filename;
  BufferedOutputStream stream;
  size=Integer.parseInt(PROPERTIES.getProperty("HistorySize","50"));
  from=m_CommandHistory.size() - size;
  if (from < 0)   from=0;
  PROPERTIES.setProperty("HistorySize","" + size);
  for (i=from; i < m_CommandHistory.size(); i++)   PROPERTIES.setProperty("Command" + (i - from),(String)m_CommandHistory.get(i));
  try {
    filename=System.getProperties().getProperty("user.home") + File.separatorChar + FILENAME;
    stream=new BufferedOutputStream(new FileOutputStream(filename));
    PROPERTIES.store(stream,"SimpleCLI");
    stream.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Project Name: weka Package: weka.gui.sql

Source Code: SqlViewer.java (Click to view .java file)

Method Code:
vote
like

/** 
 * saves the history properties of the SqlViewer in the user's home directory.
 * @see #HISTORY_FILE
 */
protected void saveHistory(){
  BufferedOutputStream str;
  try {
    str=new BufferedOutputStream(new FileOutputStream(getHistoryFilename()));
    m_History.store(str,"SQL-Viewer-History");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Project Name: weka Package: weka.gui.visualize

Source Code: PostscriptWriter.java (Click to view .java file)

Method Code:
vote
like

/** 
 * generates the actual output
 * @throws Exception	if something goes wrong
 */
public void generateOutput() throws Exception {
  BufferedOutputStream ostrm;
  PostscriptGraphics psg;
  ostrm=null;
  try {
    ostrm=new BufferedOutputStream(new FileOutputStream(getFile()));
    psg=new PostscriptGraphics(getComponent().getHeight(),getComponent().getWidth(),ostrm);
    psg.setFont(getComponent().getFont());
    psg.scale(getXScale(),getYScale());
    getComponent().printAll(psg);
    psg.finished();
  }
 catch (  Exception e) {
    System.err.println(e);
  }
 finally {
    if (ostrm != null) {
      try {
        ostrm.close();
      }
 catch (      Exception e) {
      }
    }
  }
}