List of usage examples for java.nio.file Files createTempDirectory
public static Path createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs) throws IOException
From source file:debrepo.teamcity.archive.DebFileReader.java
public Map<String, String> getMetaDataFromPackage(String filename) throws IOException { Path ephemeralTempDir = Files.createTempDirectory(Paths.get(this.myTempDirectory), "deb-temp-", new FileAttribute<?>[] {}); File debFile = new File(this.myArtifactsBaseDirectory + File.separator + filename); File controlTarGz = this.getControlTarGzFromDeb(debFile, ephemeralTempDir.toFile()); String controlFileContents = this.getControlFromControlTarGz(controlTarGz); Map<String, String> debItems = this.getDebItemsFromControl(debFile, controlFileContents); controlTarGz.delete();/*from w w w .jav a2s . c o m*/ ephemeralTempDir.toFile().delete(); return debItems; }
From source file:debrepo.teamcity.archive.ArStreamerTest.java
@Test public void getControlFileAsStringTest() throws IOException { Path ephemeralTempDir = Files.createTempDirectory(Paths.get("target"), "deb-temp-", new FileAttribute<?>[] {}); File debFile = new File("src/test/resources/build-essential_11.6ubuntu6_amd64.deb"); DebFileReader reader = new DebFileReader(new File("src/test/resources"), "target"); File controlTarGz = reader.getControlTarGzFromDeb(debFile, ephemeralTempDir.toFile()); String controlFileContents = reader.getControlFromControlTarGz(controlTarGz); System.out.println(controlFileContents); Map<String, String> params = reader.getDebItemsFromControl(debFile, controlFileContents); assertTrue(params.size() > 0);/* w w w . j a v a2s . c o m*/ for (String key : params.keySet()) { System.out.println("##" + key + "##:??" + params.get(key) + "??"); } }
From source file:debrepo.teamcity.archive.ArStreamerTest.java
@Test public void getControlFileAsStringFromAllTest() throws IOException { Path ephemeralTempDir = Files.createTempDirectory(Paths.get("target"), "deb-temp-", new FileAttribute<?>[] {}); File debFile = new File("src/test/resources/packages_for_testing/debhelper_9.20120909_all.deb"); DebFileReader reader = new DebFileReader(new File("src/test/resources/packages_for_testing"), "target"); File controlTarGz = reader.getControlTarGzFromDeb(debFile, ephemeralTempDir.toFile()); String controlFileContents = reader.getControlFromControlTarGz(controlTarGz); System.out.println(controlFileContents); Map<String, String> params = reader.getDebItemsFromControl(debFile, controlFileContents); assertTrue(params.size() > 0);/*from www .ja va 2 s.c o m*/ for (String key : params.keySet()) { System.out.println("##" + key + "##:??" + params.get(key) + "??"); } }
From source file:debrepo.teamcity.archive.ArStreamerTest.java
@Test public void getControlFileAsStringFromAllTest2() throws IOException { Path ephemeralTempDir = Files.createTempDirectory(Paths.get("target"), "deb-temp-", new FileAttribute<?>[] {}); File debFile = new File("src/test/resources/packages_for_testing/autoconf_2.69-8_all.deb"); DebFileReader reader = new DebFileReader(new File("src/test/resources/packages_for_testing"), "target"); File controlTarGz = reader.getControlTarGzFromDeb(debFile, ephemeralTempDir.toFile()); String controlFileContents = reader.getControlFromControlTarGz(controlTarGz); System.out.println(controlFileContents); Map<String, String> params = reader.getDebItemsFromControl(debFile, controlFileContents); assertTrue(params.size() > 0);/* w w w . j a v a 2 s . c o m*/ for (String key : params.keySet()) { System.out.println("##" + key + "##:??" + params.get(key) + "??"); } }
From source file:debrepo.teamcity.archive.ArStreamerTest.java
@Test public void getControlFileAsStringTest2() throws IOException { Path ephemeralTempDir = Files.createTempDirectory(Paths.get("target"), "deb-temp-", new FileAttribute<?>[] {}); File debFile = new File("src/test/resources/packages_for_testing/e3_2.71-1_amd64.deb"); DebFileReader reader = new DebFileReader(new File("src/test/resources/packages_for_testing"), "target"); File controlTarGz = reader.getControlTarGzFromDeb(debFile, ephemeralTempDir.toFile()); String controlFileContents = reader.getControlFromControlTarGz(controlTarGz); System.out.println(controlFileContents); Map<String, String> params = reader.getDebItemsFromControl(debFile, controlFileContents); assertTrue(params.size() > 0);/*from w ww . j a va 2s . c o m*/ for (String key : params.keySet()) { System.out.println("##" + key + "##:??" + params.get(key) + "??"); } }
From source file:org.apache.hadoop.hive.llap.cache.BuddyAllocator.java
@VisibleForTesting public BuddyAllocator(boolean isDirectVal, boolean isMappedVal, int minAllocVal, int maxAllocVal, int arenaCount, long maxSizeVal, long defragHeadroom, String mapPath, MemoryManager memoryManager, LlapDaemonCacheMetrics metrics, String discardMethod) { isDirect = isDirectVal;//from w w w .j a va 2s.c o m isMapped = isMappedVal; minAllocation = minAllocVal; maxAllocation = maxAllocVal; if (isMapped) { try { cacheDir = Files.createTempDirectory(FileSystems.getDefault().getPath(mapPath), "llap-", RWX); } catch (IOException ioe) { // conf validator already checks this, so it will never trigger usually throw new AssertionError("Configured mmap directory should be writable", ioe); } } else { cacheDir = null; } arenaSize = validateAndDetermineArenaSize(arenaCount, maxSizeVal); maxSize = validateAndDetermineMaxSize(maxSizeVal); memoryManager.updateMaxSize(determineMaxMmSize(defragHeadroom, maxSize)); minAllocLog2 = 31 - Integer.numberOfLeadingZeros(minAllocation); maxAllocLog2 = 31 - Integer.numberOfLeadingZeros(maxAllocation); arenaSizeLog2 = 63 - Long.numberOfLeadingZeros(arenaSize); maxArenas = (int) (maxSize / arenaSize); arenas = new Arena[maxArenas]; for (int i = 0; i < maxArenas; ++i) { arenas[i] = new Arena(); } Arena firstArena = arenas[0]; firstArena.init(0); allocatedArenas.set(1); this.memoryManager = memoryManager; defragCounters = new AtomicLong[maxAllocLog2 - minAllocLog2 + 1]; for (int i = 0; i < defragCounters.length; ++i) { defragCounters[i] = new AtomicLong(0); } this.metrics = metrics; metrics.incrAllocatedArena(); boolean isBoth = null == discardMethod || "both".equalsIgnoreCase(discardMethod); doUseFreeListDiscard = isBoth || "freelist".equalsIgnoreCase(discardMethod); doUseBruteDiscard = isBoth || "brute".equalsIgnoreCase(discardMethod); ctxPool = new FixedSizedObjectPool<DiscardContext>(32, new FixedSizedObjectPool.PoolObjectHelper<DiscardContext>() { @Override public DiscardContext create() { return new DiscardContext(); } @Override public void resetBeforeOffer(DiscardContext t) { } }); }
From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.AreaServiceBean.java
@Override @Interceptors(SimpleTracingInterceptor.class) public UploadMetadata metadata(byte[] bytes, String type) { UploadMetadata response = new UploadMetadata(); try {//w w w. ja va 2s. c o m if (bytes.length == 0) { throw new IllegalArgumentException("File is empty."); } AreaLocationTypesEntity typeName = repository.findAreaLocationTypeByTypeName(type.toUpperCase()); if (typeName == null) { throw new ServiceException("TYPE NOT SUPPORTED"); } BaseEntity instance = EntityFactory.getInstance(typeName.getTypeName()); List<Field> properties = instance.listMembers(); for (Field field : properties) { UploadProperty uploadProperty = new UploadProperty(); uploadProperty.withName(field.getName()).withType(field.getType().getSimpleName()); response.getDomain().add(uploadProperty); } Path uploadPath = Paths.get("app/upload/spatial"); uploadPath.toFile().mkdirs(); Path absolutePath = Files.createTempDirectory(uploadPath, null, new FileAttribute[0]); ZipExtractor.unZipFile(bytes, absolutePath); ZipExtractor.renameFiles(absolutePath, typeName.getTypeName()); List<UploadProperty> propertyList = UploadUtil.readAttribute(absolutePath); response.getFile().addAll(propertyList); response.withAdditionalProperty("ref", absolutePath.toString()); } catch (Exception ex) { throw new SpatialServiceException(SpatialServiceErrors.INVALID_UPLOAD_AREA_DATA, ex); } return response; }