當前位置: 首頁>>代碼示例>>Java>>正文


Java Files.size方法代碼示例

本文整理匯總了Java中java.nio.file.Files.size方法的典型用法代碼示例。如果您正苦於以下問題:Java Files.size方法的具體用法?Java Files.size怎麽用?Java Files.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.file.Files的用法示例。


在下文中一共展示了Files.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PhotatoVideo

import java.nio.file.Files; //導入方法依賴的package包/類
public PhotatoVideo(Path rootFolder, Path path, Metadata metadata, PictureInfos thumbnailInfos, PictureInfos fullScreenInfos, long lastModificationTimestamp) {
    super("video", rootFolder, path, metadata, thumbnailInfos, fullScreenInfos, lastModificationTimestamp);

    if (this.filename.length() > 40 || this.filename.contains("_") || this.filename.toLowerCase().startsWith("vid")) {
        this.name = path.getParent().getFileName().toString();
    } else {
        this.name = path.getParent().getFileName() + "/" + this.filename;
    }

    this.videoType = "video/" + FileHelper.getExtension(path.toString()).toLowerCase();
    this.videoPath = Routes.rawVideosRootUrl + "/" + PathHelper.getPathString(rootFolder, path);

    long tmpFilesize;
    try {
        tmpFilesize =Files.size(this.fsPath);
    } catch (IOException ex) {
       tmpFilesize=0;
    }
    this.filesize = tmpFilesize;
}
 
開發者ID:trebonius0,項目名稱:Photato,代碼行數:21,代碼來源:PhotatoVideo.java

示例2: accept

import java.nio.file.Files; //導入方法依賴的package包/類
@Override
public boolean accept(Media candidate) {
    Path file = scanSettings.getBaseInputDir().resolve(candidate.getSourcePath());
    try {
        long size = Files.size(file);
        if (minSize > 0 && maxSize > 0) {
            // file between max and min
            return logAndReturn(size >= minSize && size <= maxSize, file, size);
        } else if (minSize <= 0) {
            // size smaller than max, min disabled
            return logAndReturn(size <= maxSize, file, size);
        } else {
            // size greater than min, max disabled
            return logAndReturn(size >= minSize, file, size);
        }
    } catch (IOException e) {
        log.warn("Could not determine file size of {}: {}. Declined file.", file, e.toString());
        return false;
    }
}
 
開發者ID:ccremer,項目名稱:clustercode,代碼行數:21,代碼來源:FileSizeConstraint.java

示例3: calculateSize

import java.nio.file.Files; //導入方法依賴的package包/類
public String calculateSize(File f){
    String s;long sizeInByte=0; Path path;
    if(IsDrive(f)){
        return Long.toString(f.getTotalSpace()/(1024*1024*1024))+"GB";
    }

    path = Paths.get(f.toURI());
    //sizeInByte = f.getTotalSpace(); // terrible idea cz sob subfolder e 199GB, 99GB esob dekhay >_<
    try {
        sizeInByte = Files.size(path);//at least works ^_^
    } catch (IOException e) {
        e.printStackTrace();
    }
    if(sizeInByte<(1024)){s = Long.toString(sizeInByte)+"B"; return s; }
    else if(sizeInByte>=(1024) && sizeInByte<(1024*1024)){ long sizeInKb = sizeInByte/1024; s = Long.toString(sizeInKb)+"KB"; return s; }
    else if(sizeInByte>=(1024*1024) && sizeInByte<(1024*1024*1024)){ long sizeInMb = sizeInByte/(1024*1024); s = Long.toString(sizeInMb)+"MB"; return s; }
    else if(sizeInByte>=(1024*1024*1024)){ long sizeInGb = sizeInByte/(1024*1024*1024); s = Long.toString(sizeInGb)+"GB"; return s; }

    return null;
}
 
開發者ID:maximstewart,項目名稱:UDE,代碼行數:21,代碼來源:FileExplorerFx.java

示例4: StateFile

import java.nio.file.Files; //導入方法依賴的package包/類
public StateFile(Path file) throws IOException {
    this.fileCounts = new int[MAX_FILES];
    this.randomWrite = new RandomAccessFile(file.toFile(), "rw");
    if (Files.exists(file) && Files.size(file) == EXPECTED_SIZE) {
        try (DataInputStream stream = new DataInputStream(new FileInputStream(file.toFile()))) {
            readFile = stream.readShort();
            writeFile = stream.readShort();
            readPosition = stream.readInt();
            writePosition = stream.readInt();
            count = stream.readLong();
            bytes = stream.readLong();
            for (int i = 0; i < MAX_FILES; i++)
                fileCounts[i] = stream.readInt();
            unflushed = 0;
        }
    }
}
 
開發者ID:intelie,項目名稱:disq,代碼行數:18,代碼來源:StateFile.java

示例5: equals

import java.nio.file.Files; //導入方法依賴的package包/類
public boolean equals(Path path) {
	try {
		if (this.path != null) return Files.isSameFile(path, this.path);

		if (!getSanitizedFileName(path).equals(fileName)) return false;
		if (Files.size(path) != size) return false;

		return Arrays.equals(sha256, hash(path));
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:13,代碼來源:InputFile.java

示例6: streamBinaryData

import java.nio.file.Files; //導入方法依賴的package包/類
public static BinaryData streamBinaryData(Path p) {
    try {
        final long size = Files.size(p);
        final InputStream dataStream = Files.newInputStream(p);

        return new BinaryData(dataStream, size);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:11,代碼來源:Helpers.java

示例7: getCharContent

import java.nio.file.Files; //導入方法依賴的package包/類
@Override
public final CharSequence getCharContent(final boolean ignoreEncodingErrors) throws IOException {
    final long len = Files.size(resolvePath());
    return FileObjects.getCharContent(
            openInputStream(),
            encoding,
            null,
            len,
            ignoreEncodingErrors);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:FileObjects.java

示例8: processedFileIsSmaller

import java.nio.file.Files; //導入方法依賴的package包/類
@Test
public void processedFileIsSmaller() throws Throwable {
  long original = Files.size(getOriginalDexFile());
  long generated = Files.size(getGeneratedDexFile());
  final boolean ALWAYS_DUMP = false;  // Used for debugging.
  if (ALWAYS_DUMP || generated > original) {
    dump(getOriginalDexFile(), "Original");
    dump(getGeneratedDexFile(), "Generated");
  }
  assertTrue("Inlining failed to reduce size", original > generated);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:12,代碼來源:R8InliningTest.java

示例9: getFileSize

import java.nio.file.Files; //導入方法依賴的package包/類
public long getFileSize() {
    try {
        return Files.size(path);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return 0;
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:9,代碼來源:FileBucket.java

示例10: FileEntry

import java.nio.file.Files; //導入方法依賴的package包/類
FileEntry(Path path, String name) {
    super(DirArchive.this, getPathName(path), name,
          Archive.Entry.EntryType.CLASS_OR_RESOURCE);
    this.path = path;
    try {
        size = Files.size(path);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:DirArchive.java

示例11: size

import java.nio.file.Files; //導入方法依賴的package包/類
public long size() {
	try {
		return Files.size(file);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return -1;
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:9,代碼來源:FileInputStreamDataSource.java

示例12: scanMetadata

import java.nio.file.Files; //導入方法依賴的package包/類
private boolean scanMetadata(URI uri) {
  var meta = read(uri.resolve("maven-metadata.xml")).orElseThrow(Error::new);
  if (meta.contains("<versioning>")) {
    var updated = substring(meta, "<lastUpdated>", "<");
    if (updated.length() != 14) {
      System.out.println("  [!] unexpected <lastUpdated> format: " + updated);
      return true;
    }
    if (updated.compareTo("20170101000000") < 0) {
      System.out.println("  [!] too old: " + updated);
      return true;
    }
    var group = substring(meta, "<groupId>", "<");
    var artifact = substring(meta, "<artifactId>", "<");
    var version = substring(meta, "<release>", "<"); // TODO Consider 'latest'?
    try {
      // TODO load .pom and assume "jar" packaging
      var jar = load(uri.resolve(version + "/" + artifact + "-" + version + ".jar"));
      if (Files.exists(jar) && Files.size(jar) > 0) {
        scanJar(jar, group, artifact, version);
      }
      Files.deleteIfExists(jar);
    } catch (Exception e) {
      throw new Error("Scanning maven-metadata.xml failed!", e);
    }
    return true;
  }
  return false;
}
 
開發者ID:sormuras,項目名稱:bach,代碼行數:30,代碼來源:GenerateModuleProperties.java

示例13: getSize

import java.nio.file.Files; //導入方法依賴的package包/類
@Override
public long getSize() {
    if(Files.exists(Paths.get(path))) {
        try {
            return Files.size(Paths.get(path));
        }
        catch(IOException e) {
            log.warn(String.format("Failure getting size of %s. %s", path, e.getMessage()));
        }
    }
    return -1;
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:13,代碼來源:LocalAttributes.java

示例14: gc

import java.nio.file.Files; //導入方法依賴的package包/類
private void gc() throws IOException {
    Path file = makeDataPath(state.getReadFile());
    boolean shouldFlush = false;
    while (!Files.exists(file) && !state.sameFileReadWrite()) {
        state.advanceReadFile(0);
        file = makeDataPath(state.getReadFile());
        shouldFlush = true;
    }
    long totalBytes = 0;
    long totalCount = 0;
    for (int i = 0; i < StateFile.MAX_FILES; i++) {
        Path path = makeDataPath(i);
        if (Files.exists(path)) {
            if (!state.isInUse(i)) {
                tryDeleteFile(i, false);
            } else {
                totalBytes += Files.size(path);
                totalCount += state.getFileCount(i);
            }
        }
    }

    shouldFlush |= state.fixCounts(totalCount, totalBytes);

    if (shouldFlush)
        internalFlush();

}
 
開發者ID:intelie,項目名稱:disq,代碼行數:29,代碼來源:DiskRawQueue.java

示例15: ZipFileStoreAttributes

import java.nio.file.Files; //導入方法依賴的package包/類
public ZipFileStoreAttributes(ZipFileStore fileStore)
    throws IOException
{
    Path path = FileSystems.getDefault().getPath(fileStore.name());
    this.size = Files.size(path);
    this.fstore = Files.getFileStore(path);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:ZipFileStore.java


注:本文中的java.nio.file.Files.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。