List of utility methods to do Path Extract nio
void | extract(Path archive, Path targetDirectory) Extracts a ZIP archive into the target directory System.out.println("Unzipping " + archive.getFileName().toString() + "..."); byte[] buffer = new byte[bufferSize]; try (ZipInputStream zin = new ZipInputStream(new FileInputStream(archive.toFile()))) { ZipEntry ze; while ((ze = zin.getNextEntry()) != null) { Path extractedFile = targetDirectory.resolve(ze.getName()); try (FileOutputStream fout = new FileOutputStream(extractedFile.toFile())) { int len; ... |
String | extractClassName(Path path) Extracts the actual Class-Name from the given Path which should be a Path to a Class-File If the given Path does not discribe a Class-File the result may be completly unusable String className = path.toString(); return className.substring(1, className.length() - CLASS_FILE_ENDING.length()).replace('/', '.'); |
String | extractCurrentPath() extract Current Path return Paths.get(".").toAbsolutePath().normalize().toString(); |
void | extractFile(ZipInputStream zipIn, Path filePath) Extracts a zip entry (file entry) BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(filePath.toFile().getAbsolutePath())); byte[] bytesIn = new byte[BUFFER_SIZE]; int read = 0; while ((read = zipIn.read(bytesIn)) != -1) { bos.write(bytesIn, 0, read); bos.close(); ... |
String | extractLanguageRelativePath(final Path absolutePath) extract Language Relative Path final String fileName; if (absolutePath != null && absolutePath.getFileName() != null) { fileName = absolutePath.getFileName().toString(); } else { fileName = ""; final String pathRegexSeparator; if ("\\".equals(File.separator)) { ... |
StackTraceElement[] | extractLuaStacktrace(Path path, StackTraceElement[] stackTrace) extract Lua Stacktrace if (stackTrace == null || stackTrace.length == 0) { return new StackTraceElement[0]; List<StackTraceElement> luaStackTrace = new ArrayList<>(); String pathAsString = path.toString().replace('.', '/'); for (StackTraceElement stackTraceElement : stackTrace) { String fileName = stackTraceElement.getFileName(); if (fileName != null && fileName.startsWith(pathAsString)) { ... |
String | extractVersion(Path pathToBinaries) extract Version return pathToBinaries.getParent().getFileName().toString();
|
void | extractZipArchive(final File zipFile, Path destDir) extract Zip Archive if (!destDir.toFile().exists() || !destDir.toFile().isDirectory()) { throw new IllegalArgumentException("can only unzip to directory"); if (!zipFile.exists()) { throw new IllegalArgumentException("zip file not found"); try (FileSystem zipFileSystem = FileSystems.newFileSystem(zipFile.toPath(), null)) { final Path root = zipFileSystem.getPath("/"); ... |
void | unzipFileInArchive(FileChannel channel, String relpathInZip, File extractTo) unzip File In Archive relpathInZip = relpathInZip.replace("\\", "/"); Pattern pattern = Pattern.compile(wildcardToRegex(relpathInZip), Pattern.CASE_INSENSITIVE); ZipInputStream stream = new ZipInputStream(Channels.newInputStream(channel)); ZipEntry entry; while ((entry = stream.getNextEntry()) != null) { File file = new File(extractTo, entry.getName()); String name = '/' + entry.getName(); Matcher matcher = pattern.matcher(name); ... |