List of usage examples for java.io File getAbsolutePath
public String getAbsolutePath()
From source file:Main.java
static public String initSavePath() { File dateDir = Environment.getExternalStorageDirectory(); String path = dateDir.getAbsolutePath() + "/corp/"; File folder = new File(path); if (!folder.exists()) { folder.mkdir();//ww w. j a v a 2s . c om } return path; }
From source file:Main.java
public static Bitmap File2Bitmap(File file) { if (file != null) { return BitmapFactory.decodeFile(file.getAbsolutePath()); } else {/*from w w w.j a v a 2 s. c o m*/ return null; } }
From source file:Main.java
public static File createTemporaryFile(String part, String ext) throws Exception { File tempDir = Environment.getExternalStorageDirectory(); tempDir = new File(tempDir.getAbsolutePath() + "/.temp/"); if (!tempDir.exists()) { tempDir.mkdirs();// w w w. j a v a 2s .c om } return File.createTempFile(part, ext, tempDir); }
From source file:Main.java
public static File createTemporaryFile(String part, String ext) throws Exception { File tempDir = Environment.getExternalStorageDirectory(); tempDir = new File(tempDir.getAbsolutePath() + "/.temp/"); if (!tempDir.exists()) { tempDir.mkdir();//ww w. j a va2 s. co m } return File.createTempFile(part, ext, tempDir); }
From source file:Main.java
public static String getFilePath(File dirPath, String fileName) { try {// ww w.jav a2s . com String filePath = dirPath.getAbsolutePath() + File.separator + URLEncoder.encode(fileName.replace("*", ""), "UTF-8"); return filePath; } catch (final UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Document getDomDocument(File xmlFile) throws Exception { InputStream in = new URL("file:///" + xmlFile.getAbsolutePath()).openStream(); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbFactory.newDocumentBuilder(); Document xmlDoc = docBuilder.parse(in); in.close();/* ww w . ja va 2 s.c om*/ return xmlDoc; }
From source file:Main.java
public static File getHomeFileLoc() { File sdcard = Environment.getExternalStorageDirectory(); File sdpath = new File(sdcard.getAbsolutePath() + File.separator + "KnouNotice"); if (!sdpath.exists()) { boolean flag = sdpath.mkdirs(); }//from ww w . j a v a 2 s . c o m return sdpath; }
From source file:Main.java
/** * Extracts the EXIF rotation tag of an image file. * * @param file The image file/* www.jav a 2 s. c o m*/ * @return Rotation in degrees * @throws IOException */ public static int getExifRotation(File file) throws IOException { return getExifRotation(file.getAbsolutePath()); }
From source file:Main.java
public static String getApplicationFilePath(Context context) { File filesDir = context.getFilesDir(); if (filesDir != null) { return filesDir.getAbsolutePath(); }//from ww w . ja v a 2s . co m return "Couldn't retrieve ApplicationFilePath"; }
From source file:Main.java
private static void clearDir(String projectDir) { File file = new File(projectDir); File[] files = file.listFiles(); if (files == null || files.length == 0) { return;// w w w . jav a2 s.co m } for (File f : files) { if (f.isDirectory()) { clearDir(f.getAbsolutePath()); } else { f.delete(); } } }