当前位置: 首页>>代码示例>>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;未经允许,请勿转载。