There are 4 code examples for java.io.DataOutputStream.

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: icTAKES Package: edu.mayo.bmi.uima.drugner.cc

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

Method Code:
vote
like

/** 
 * Loads text from a file. Specialized to load array idAndDate and return it
 * too
 * @param filename
 * @return
 * @throws FileNotFoundException
 * @throws IOException
 */
public void store(String filename,String lineToStore) throws FileNotFoundException, IOException {
  int howMany=132;
  boolean skipDate=false;
  boolean preExists=true;
  if (filename.endsWith(System.getProperty("file.separator")))   filename=filename + lineToStore.substring(0,lineToStore.indexOf(',')) + ".csv";
 else   filename=filename + "/" + lineToStore.substring(0,lineToStore.indexOf(','))+ ".csv";
  File f=new File(filename);
  if (!f.exists()) {
    f.createNewFile();
    preExists=false;
  }
  BufferedReader br=new BufferedReader(new FileReader(f));
  br.readLine();
  br.close();
  ByteArrayOutputStream bout=new ByteArrayOutputStream(howMany * 4);
  DataOutputStream dout=new DataOutputStream(bout);
  FileOutputStream fos=new FileOutputStream(filename,true);
  if (!preExists) {
    dout.writeBytes(drugHeaders);
  }
  if (!skipDate)   dout.writeBytes(lineToStore + '\n');
  try {
    if (!skipDate) {
      bout.writeTo(fos);
      fos.flush();
    }
  }
  finally {
    fos.close();
  }
}
 

Project Name: icTAKES Package: edu.mayo.bmi.uima.termspotter.cc

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

Method Code:
vote
like

/** 
 * Loads text from a file. Specialized to load array idAndDate and return it
 * too
 * @param filename
 * @return
 * @throws FileNotFoundException
 * @throws IOException
 */
private void store(String filename,String lineToStore) throws FileNotFoundException, IOException {
  int howMany=132;
  boolean skipDate=false;
  File f=new File(filename);
  if (!f.exists())   f.createNewFile();
  ByteArrayOutputStream bout=new ByteArrayOutputStream(howMany * 4);
  DataOutputStream dout=new DataOutputStream(bout);
  FileOutputStream fos=new FileOutputStream(filename,true);
  if (!skipDate)   dout.writeBytes(lineToStore + '\n');
  try {
    if (!skipDate) {
      bout.writeTo(fos);
      fos.flush();
    }
  }
  finally {
    fos.close();
    bout.close();
    dout.close();
  }
}
 

Project Name: megamek Package: megamek.common.net

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

Method Code:
vote
like

/** 
 * override flush to flush the datastream after flushing packetqueue
 */
@Override public synchronized void flush(){
  super.flush();
  try {
    if (out != null)     out.flush();
  }
 catch (  IOException ioe) {
    ioe.printStackTrace();
    close();
  }
}
 

Project Name: weka Package: weka.experiment

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

Method Code:
vote
like

/** 
 * Closes the zip file.
 * @throws Exception if something goes wrong
 */
public void finished() throws Exception {
  if (m_zipOut != null) {
    m_zipOut.close();
  }
}