List of usage examples for java.io File getPath
public String getPath()
From source file:mesclasses.model.FileConfigurationManager.java
private static void writeCustomProperties(File pFile) { try (FileOutputStream out = new FileOutputStream(pFile.getPath())) { customProperties.store(out, null); } catch (IOException e) { }/* w w w.j av a 2s .co m*/ }
From source file:mesclasses.util.EleveFileUtil.java
public static String copyFileForEleve(Eleve eleve, File file, String type) throws IOException { File eleveDir = getEleveDirWithType(eleve, type); eleveDir.mkdirs();//from w ww . j a v a2 s . c o m String fileName = FilenameUtils.getName(file.getPath()); File newFile = new File(eleveDir.getPath() + File.separator + fileName); if (newFile.exists()) { throw new IOException( "Le fichier " + fileName + " de type " + type + " existe dj pour " + eleve.getFirstName()); } FileUtils.copyFile(file, newFile); return newFile.getPath(); }
From source file:mesclasses.util.EleveFileUtil.java
public static String moveFileForEleve(Eleve eleve, File file, String type) throws IOException { File eleveDir = getEleveDirWithType(eleve, type); eleveDir.mkdirs();/*from w w w . j av a 2 s. co m*/ String fileName = FilenameUtils.getName(file.getPath()); File newFile = new File(eleveDir.getPath() + File.separator + fileName); if (newFile.exists()) { throw new IOException( "Le fichier " + fileName + " de type " + type + " existe dj pour " + eleve.getFirstName()); } FileUtils.moveFile(file, newFile); return newFile.getPath(); }
From source file:de.thischwa.pmcms.tool.PathTool.java
/** * Changes an application context relative file to an absolute url. * /* ww w . ja v a 2 s . c om*/ * @param fileName * @return url */ public static String getURLFromFile(final String fileName, boolean encode) { File file = new File(fileName); String temp = file.getPath().replace(File.separatorChar, '/'); if (encode) temp = encodePath(temp); return (temp.startsWith("/")) ? temp : "/".concat(temp); }
From source file:net.idlesoft.android.apps.github.utils.GravatarCache.java
/** * Returns a Bitmap of the Gravatar associated with the provided ID. This * image will be scaled according to the provided size. * /* w ww. ja va 2 s .co m*/ * @param id * @param size * @return a scaled Bitmap */ public static Bitmap getGravatar(final String id, final int size) { Bitmap bm = null; try { final File gravatars = ensure_directory(ROOT_DIR); /* Prevents the gravatars from showing up in the Gallery app */ hideMediaFromGallery(gravatars); final File image = new File(gravatars, id + ".png"); bm = BitmapFactory.decodeFile(image.getPath()); if (bm == null) { bm = downloadGravatar(id); /* Compress to a 100x100px PNG */ bm.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(image)); } bm = Bitmap.createScaledBitmap(bm, size, size, true); } catch (final IOException e) { Log.e("debug", "Error saving bitmap", e); e.printStackTrace(); } return bm; }
From source file:io.proleap.vb6.TestGenerator.java
public static void generateTestClasses(final File inputDirectory, final File outputDirectory, final String packageName) throws IOException { final String outputDirectoryPath = outputDirectory.getPath(); if (inputDirectory.isDirectory()) { // for each of the files in the directory for (final File inputDirectoryFile : inputDirectory.listFiles()) { // if the file is a VB6 relevant file if (inputDirectoryFile.isFile() && !inputDirectoryFile.isHidden() && (isClazzModule(inputDirectoryFile) || isStandardModule(inputDirectoryFile))) { generateTestClass(inputDirectoryFile, outputDirectory, packageName); generateTreeFile(inputDirectoryFile, inputDirectory); }/*from w w w .j a v a 2s.c o m*/ // else, if the file is a relevant directory else if (inputDirectoryFile.isDirectory() && !isDirectoryExcluded(inputDirectoryFile)) { final File subInputDirectory = inputDirectoryFile; final String subInputDirectoryName = subInputDirectory.getName(); if (!".".equals(subInputDirectoryName) && !"..".equals(subInputDirectoryName)) { /* * determine the output directory, where test classes * should be placed */ final File subOutputDirectory = new File(outputDirectoryPath + "/" + subInputDirectoryName); subOutputDirectory.mkdirs(); // determine the package name of test classes final String subPackageName = Strings.isBlank(packageName) ? subInputDirectoryName : packageName + "." + subInputDirectoryName; generateTestClasses(subInputDirectory, subOutputDirectory, subPackageName); } } } } }
From source file:MakeDirectories.java
private static void fileData(File f) { System.out.println("Absolute path: " + f.getAbsolutePath() + "\n Can read: " + f.canRead() + "\n Can write: " + f.canWrite() + "\n getName: " + f.getName() + "\n getParent: " + f.getParent() + "\n getPath: " + f.getPath() + "\n length: " + f.length() + "\n lastModified: " + f.lastModified());/*from www .java 2 s. c o m*/ if (f.isFile()) System.out.println("It's a file"); else if (f.isDirectory()) System.out.println("It's a directory"); }
From source file:Main.java
public static void disImage(Activity act, File file) { Intent itt = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); itt.setData(Uri.fromFile(file));/* ww w.j a v a2 s .c o m*/ act.sendBroadcast(itt); Intent it = new Intent(Intent.ACTION_VIEW); it.setDataAndType(Uri.parse(file.getPath()), "image/*"); act.startActivity(it); }
From source file:com.openkm.util.ImageUtils.java
/** * Execute ImageMagick convert with parameters. *//*from w w w . j a v a 2s . co m*/ public static void ImageMagickConvert(File input, File output, String params) { ImageMagickConvert(input.getPath(), output.getPath(), params); }
From source file:Main.java
/** * Decodes an image File to Bitmap resizing the image to fit the <code>requestedWidth</code> and <code>requestedHeight</code> dimensions. * @param file the image file reference// w w w . j a v a2 s.c o m * @param requestedWidth the final image width will be close to the requestedWidth (value is in pixels) * @param requestedHeight the final image height will be close to the requestedHeight (value is in pixels) * @return the resized Bitmap */ public static Bitmap decodeSampledBitmapFromFile(File file, int requestedWidth, int requestedHeight) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(file.getPath(), options); int inSampleSize = calculateSampleSize(options, requestedWidth, requestedHeight); return decodeSampledBitmapFromFile(file, inSampleSize); }