Android Open Source - droid-aegis To File






From Project

Back to project page droid-aegis.

License

The source code is released under:

MIT License

If you think the Android project droid-aegis listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package andi.cctv.app;
// www .  jav a2 s  . c  o  m
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.os.Environment;
import android.util.Log;

public class ToFile {
  private File  mOutFile;
  private FileOutputStream mFos;
  private static final String    mTag = "cctv";

  public ToFile() {
    String extPath = Environment.getExternalStorageDirectory().getPath();
    String absPath = extPath + "/rec.bin";
    Log.d(mTag, "File is " + absPath);
    mOutFile = new File(absPath);
    if (mOutFile.exists()) {
      mOutFile.delete();
    }
    try {
      mOutFile.createNewFile();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Log.d(mTag, "File exits " + mOutFile.exists());
    Log.d(mTag, "File can write " + mOutFile.canWrite());
    mFos = null;
  }

  public FileDescriptor getOutFD () {
    try {
      mFos = new FileOutputStream(mOutFile);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    try {
      return mFos.getFD();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return null;
  }
  
  public void closeFos () {
    try {
      mFos.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
}




Java Source Code List

andi.cctv.app.MainActivity.java
andi.cctv.app.MediaController.java
andi.cctv.app.Sockit.java
andi.cctv.app.ToFile.java
andi.cctv.app.WifiCheck.java
com.app.camstreamer.BufferHandler.java
com.app.camstreamer.BufferNotifications.java
com.app.camstreamer.BufferPool.java
com.app.camstreamer.MainActivity.java
com.app.camstreamer.MockCamera.java
com.app.camstreamer.StreamSock.java