List of usage examples for java.io File getPath
public String getPath()
From source file:edu.unc.lib.dl.util.ZipFileUtil.java
/** * Unzips the contents of the zip file to the directory. * //ww w. j ava 2 s.c o m * If anything goes wrong during this process, clean up the temporary * directory and throw an exception. */ public static void unzipToDir(File zipFile, File destDir) throws IOException { log.debug("Unzipping to directory: " + destDir.getPath()); unzip(new FileInputStream(zipFile), destDir); }
From source file:Main.java
private static String createDir(String path) { boolean isHaveSDCard = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); if (!isHaveSDCard) { return null; }//from w w w . ja va2 s .c o m File directory = Environment.getExternalStorageDirectory(); File file = new File(directory.getAbsolutePath() + path); if (!file.exists()) { boolean isSuccess = file.mkdirs(); if (isSuccess) { return file.getPath() + File.separator; } else { return null; } } return file.getPath() + File.separator; }
From source file:de.fau.cs.osr.hddiff.perfsuite.HDDiffTestUtils.java
protected static File aToB(File inputFileA) { return new File(inputFileA.getPath().replaceAll("\\.a\\.wikitext$", ".b.wikitext")); }
From source file:Main.java
public static String writeBitmap(byte[] data, int cameraDegree, Rect rect, Rect willTransformRect) throws IOException { File file = new File(Environment.getExternalStorageDirectory() + "/bookclip/"); file.mkdir();// w ww. j a va 2 s . com String bitmapPath = file.getPath() + "/" + System.currentTimeMillis() + ".png"; // bitmap rotation, scaling, crop BitmapFactory.Options option = new BitmapFactory.Options(); option.inSampleSize = 2; Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, option); Matrix bitmapMatrix = new Matrix(); bitmapMatrix.setRotate(cameraDegree); int x = rect.left, y = rect.top, width = rect.right - rect.left, height = rect.bottom - rect.top; Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), bitmapMatrix, false); // bitmap recycle bitmap.recycle(); Bitmap scaledBitmap = Bitmap.createScaledBitmap(rotateBitmap, willTransformRect.right, willTransformRect.bottom - willTransformRect.top, false); // rotatebitmap recycle rotateBitmap.recycle(); Bitmap cropBitmap = Bitmap.createBitmap(scaledBitmap, x, y, width, height, null, false); // scaledBitmap recycle scaledBitmap.recycle(); // file write FileOutputStream fos = new FileOutputStream(new File(bitmapPath)); cropBitmap.compress(CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); // recycle cropBitmap.recycle(); return bitmapPath; }
From source file:Utils.java
private static void deleteContentsRecursive(File file) throws IOException { File[] files = file.listFiles(); for (File child : files) { if (child.isDirectory()) deleteContentsRecursive(child); if (!child.delete()) throw new IOException("Unable to delete " + child.getPath()); }/*from ww w . j av a 2s . c om*/ }
From source file:Main.java
public static void OutputXml(File in, String saveFileInPath) throws Exception { TransformerFactory tFactory = TransformerFactory.newInstance(); Source xslDoc = new StreamSource("backup.xslt"); Source xmlDoc = new StreamSource(in.getPath()); System.out.print(in.getName() + "/n"); String outputFileName = in.getName().split("\\.")[0]; System.out.println(outputFileName); OutputStream htmlFile;/*from www . j ava2 s .c o m*/ htmlFile = new FileOutputStream(saveFileInPath + "//" + outputFileName + ".html"); Transformer transformer = tFactory.newTransformer(xslDoc); transformer.transform(xmlDoc, new StreamResult(htmlFile)); }
From source file:asia.gkc.vneedu.utils.FileUtil.java
/** * /*from ww w. j a va 2s.c om*/ * * @param source - ? * @param destination - ? * @return ?? * @throws IOException */ public static boolean transferFile(File source, File destination) throws IOException { if (!destination.exists()) { logger.debug(destination.getPath()); destination.createNewFile(); } FileChannel src, dest; src = new FileInputStream(source).getChannel(); dest = new FileOutputStream(destination).getChannel(); long count = 0; long size = src.size(); while ((count += dest.transferFrom(src, count, size - count)) < size) ; return true; }
From source file:edu.northwestern.bioinformatics.studycalendar.web.WebTestCase.java
public static String findWebappSrcDirectory() { File dir = new File("src/main/webapp"); if (dir.exists()) { return dir.getPath(); }//from ww w. jav a 2 s . c o m dir = new File("web", dir.toString()); if (dir.exists()) { return dir.getPath(); } throw new IllegalStateException("Could not find webapp path"); }
From source file:Main.java
/** * deletes all Files and Subfolders in a directory * @param dir target directory//from w ww. j a v a2 s .c om * @return */ public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] entries = dir.list(); for (int x = 0; x < entries.length; x++) { File aktFile = new File(dir.getPath(), entries[x]); deleteDir(aktFile); } if (dir.delete()) { return true; } else { return false; } } else { if (dir.delete()) { return true; } else { return false; } } }
From source file:brut.directory.ZipUtils.java
private static void zipFolders(final File folder, final ZipOutputStream outputStream) throws BrutException, IOException { processFolder(folder, outputStream, folder.getPath().length() + 1); }