Android Open Source - dttv-android File Util






From Project

Back to project page dttv-android.

License

The source code is released under:

GNU General Public License

If you think the Android project dttv-android 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 dttv.app.utils;
//  w  ww  .j a v  a2s .c o m
import java.io.File;
import java.io.IOException;

import android.net.Uri;
import android.text.TextUtils;

/**
 * 
 * @author shihx1
 * @aim handle file
 */
public class FileUtil {
  
  public static String getCanonical(File file){
    if(file == null)
      return null;
    try {
      return file.getCanonicalPath();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return file.getAbsolutePath();
    }
  }
  
  public static String getPath(String uri){
    if(TextUtils.isEmpty(uri))
      return null;
    if(uri.startsWith("file://") && uri.length()>7 ){
      return Uri.decode(uri.substring(7));
    }
    return Uri.decode(uri);
  }
  
  public static String getName(String uri){
    String path = getPath(uri);
    if(path != null)
      return new File(path).getName();
    return null;
  }
  
  public static void deleteDir(File file){
    if(file.exists() && file.isDirectory()){
      for(File f:file.listFiles()){
        if(f.isDirectory())
          deleteDir(f);
        f.delete();
      }
      file.delete();
    }
  } 
}




Java Source Code List

dttv.app.DtPlayer.java
dttv.app.FileBrowserActivity.java
dttv.app.FileShowActivity.java
dttv.app.IndexActivity.java
dttv.app.MainActivity.java
dttv.app.SettingActivity.java
dttv.app.VideoPlayerActivity.java
dttv.app.adapter.FileAdapter.java
dttv.app.compnent.Compnent.java
dttv.app.compnent.MethodPlayerCompnent.java
dttv.app.compnent.PopWindowCompnent.java
dttv.app.impl.ICallBack.java
dttv.app.impl.I_Async.java
dttv.app.impl.I_KeyIntercept.java
dttv.app.impl.I_OnMyKey.java
dttv.app.impl.I_PopWindow.java
dttv.app.model.Item.java
dttv.app.multithread.DataAsyncTask.java
dttv.app.utils.Constant.java
dttv.app.utils.ControlLightness.java
dttv.app.utils.FileUtil.java
dttv.app.utils.Log.java
dttv.app.utils.MultiMediaTypeUtil.java
dttv.app.utils.MusicUtils.java
dttv.app.utils.PlayerUtil.java
dttv.app.utils.SettingUtil.java
dttv.app.utils.TimesUtil.java
dttv.app.utils.VolumeUtil.java
dttv.app.view.SimpleDialog.java
dttv.app.widget.AudioUIFragment.java
dttv.app.widget.EffectWindow.java
dttv.app.widget.FilesUIFragment.java
dttv.app.widget.GlVideoView.java
dttv.app.widget.OnTouchMoveListener.java
dttv.app.widget.SlideTabsFragment.java
dttv.app.widget.VideoUIFragment.java