List of usage examples for java.io File toString
public String toString()
From source file:net.minecraftforge.fml.common.patcher.GenDiffSet.java
public static void main(String[] args) throws IOException { String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft String deobfData = args[2]; //Path to FML's deobfusication_data.lzma String outputDir = args[3]; //Path to place generated .binpatch String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch LogManager.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir)); Delta delta = new Delta(); FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE; remapper.setupLoadOnly(deobfData, false); JarFile sourceZip = new JarFile(sourceJar); boolean kill = killTarget.equalsIgnoreCase("true"); File f = new File(outputDir); f.mkdirs();/*from w w w . ja v a2s . c o m*/ for (String name : remapper.getObfedClasses()) { // Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name)); String fileName = name; String jarName = name; if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH))) { fileName = "_" + name; } File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class"); jarName = jarName + ".class"; if (targetFile.exists()) { String sourceClassName = name.replace('/', '.'); String targetClassName = remapper.map(name).replace('/', '.'); JarEntry entry = sourceZip.getJarEntry(jarName); byte[] vanillaBytes = toByteArray(sourceZip, entry); byte[] patchedBytes = Files.toByteArray(targetFile); byte[] diff = delta.compute(vanillaBytes, patchedBytes); ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50); // Original name diffOut.writeUTF(name); // Source name diffOut.writeUTF(sourceClassName); // Target name diffOut.writeUTF(targetClassName); // exists at original diffOut.writeBoolean(entry != null); if (entry != null) { diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt()); } // length of patch diffOut.writeInt(diff.length); // patch diffOut.write(diff); File target = new File(outputDir, targetClassName + ".binpatch"); target.getParentFile().mkdirs(); Files.write(diffOut.toByteArray(), target); Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s", name, targetClassName, target.getAbsolutePath())); if (kill) { targetFile.delete(); Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString())); } } } sourceZip.close(); }
From source file:Main.java
public static boolean isFileAnImage(File file) { if (file.toString().endsWith(".jpg") || file.toString().endsWith(".jpeg") || file.toString().endsWith(".gif") || file.toString().endsWith(".png")) { return true; } else {/*from w ww. j a v a 2 s . c o m*/ return false; } }
From source file:Main.java
private static Intent getHtmlFileIntent(File file) { Uri uri = Uri.parse(file.toString()).buildUpon().encodedAuthority("com.android.htmlfileprovider") .scheme("content").encodedPath(file.toString()).build(); Intent intent = new Intent("android.intent.action.VIEW"); intent.setDataAndType(uri, "text/html"); return intent; }
From source file:Main.java
public static boolean isLosslessSupported(File f) { String s = f.toString(); if (s.endsWith(".flac") || s.endsWith(".FLAC")) return true; else if (s.endsWith(".ape") || s.endsWith(".APE")) return true; else if (s.endsWith(".wav") || s.endsWith(".WAV")) return true; else if (s.endsWith(".wv") || s.endsWith(".WV")) return true; else if (s.endsWith(".mpc") || s.endsWith(".MPC")) return true; else if (s.endsWith(".m4a") || s.endsWith(".M4A")) return true; else/* w w w . j a va 2 s . c om*/ return false; }
From source file:Main.java
/** * //ww w.j av a 2s. co m * Example usage: * <pre> * SwingUtil.createFileFilter("JEQL script (*.jql)", "jql") * </pre> * @param description * @param extension * @return the file filter */ public static FileFilter createFileFilter(final String description, String extension) { final String dotExt = extension.startsWith(".") ? extension : "." + extension; FileFilter ff = new FileFilter() { public String getDescription() { return description; } public boolean accept(File f) { return f.isDirectory() || f.toString().toLowerCase().endsWith(dotExt); } }; return ff; }
From source file:Main.java
public static void writeFiletoAndroidMediaDB(Context context, File file) { MediaScannerConnection.scanFile(context, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { }/*from w w w . j av a 2s. c o m*/ }); }
From source file:Main.java
public static String RenameFileToNewPath(String oldpath) { String path = oldpath;//from www. j a v a 2s.com path = path.replace("/mnt/sdcard/", ""); String new_path = path.replace(".ck", ""); File sdcard = Environment.getExternalStorageDirectory(); File from = new File(sdcard, oldpath); File to = new File(sdcard, new_path); from.renameTo(to); return to.toString(); }
From source file:Main.java
public static boolean createDirectory(String directoryName) { boolean status; if (!directoryName.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + directoryName); //status = newPath.mkdir(); status = true;/*from w ww .jav a 2 s. c o m*/ } else status = false; return status; }
From source file:Main.java
public static boolean checkFileExists(String name) { boolean status; if (!name.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + name); status = newPath.exists();/*www. ja v a 2s . co m*/ } else { status = false; } return status; }
From source file:Main.java
public static boolean createDirectory(String directoryName) { boolean status; if (!directoryName.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + directoryName); status = newPath.mkdir();/* ww w . j av a 2 s .com*/ status = true; } else status = false; return status; }