热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.nio.file.attribute.BasicFileAttributes.size()方法的使用及代码示例

本文整理了Java中java.nio.file.attribute.BasicFileAttributes.size()方法的一些代码示例,展示了Basic

本文整理了Java中java.nio.file.attribute.BasicFileAttributes.size()方法的一些代码示例,展示了BasicFileAttributes.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BasicFileAttributes.size()方法的具体详情如下:
包路径:java.nio.file.attribute.BasicFileAttributes
类名称:BasicFileAttributes
方法名:size

BasicFileAttributes.size介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
size += attrs.size();
return FileVisitResult.CONTINUE;
}

代码示例来源:origin: apache/ignite

@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
s.addAndGet(attrs.size());
return FileVisitResult.CONTINUE;
}

代码示例来源:origin: google/guava

@Override
public long size() throws IOException {
BasicFileAttributes attrs = readAttributes();
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory()) {
throw new IOException("can't read: is a directory");
} else if (attrs.isSymbolicLink()) {
throw new IOException("can't read: is a symbolic link");
}
return attrs.size();
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// size is specified on regular files only
// https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/BasicFileAttributes.html#size--
if (attrs.isRegularFile()) {
size += attrs.size();
}
return FileVisitResult.CONTINUE;
}
}

代码示例来源:origin: google/guava

@Override
public Optional sizeIfKnown() {
BasicFileAttributes attrs;
try {
attrs = readAttributes();
} catch (IOException e) {
// Failed to get attributes; we don't know the size.
return Optional.absent();
}
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory() || attrs.isSymbolicLink()) {
return Optional.absent();
}
return Optional.of(attrs.size());
}

代码示例来源:origin: prestodb/presto

@Override
public long size() throws IOException {
BasicFileAttributes attrs = readAttributes();
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory()) {
throw new IOException("can't read: is a directory");
} else if (attrs.isSymbolicLink()) {
throw new IOException("can't read: is a symbolic link");
}
return attrs.size();
}

代码示例来源:origin: google/j2objc

@Override
public long size() throws IOException {
BasicFileAttributes attrs = readAttributes();
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory()) {
throw new IOException("can't read: is a directory");
} else if (attrs.isSymbolicLink()) {
throw new IOException("can't read: is a symbolic link");
}
return attrs.size();
}

代码示例来源:origin: google/j2objc

@Override
public Optional sizeIfKnown() {
BasicFileAttributes attrs;
try {
attrs = readAttributes();
} catch (IOException e) {
// Failed to get attributes; we don't know the size.
return Optional.absent();
}
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory() || attrs.isSymbolicLink()) {
return Optional.absent();
}
return Optional.of(attrs.size());
}

代码示例来源:origin: stackoverflow.com

public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
size.addAndGet(attrs.size());
return FileVisitResult.CONTINUE;

代码示例来源:origin: wildfly/wildfly

@Override
public long size() throws IOException {
BasicFileAttributes attrs = readAttributes();
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory()) {
throw new IOException("can't read: is a directory");
} else if (attrs.isSymbolicLink()) {
throw new IOException("can't read: is a symbolic link");
}
return attrs.size();
}

代码示例来源:origin: wildfly/wildfly

@Override
public Optional sizeIfKnown() {
BasicFileAttributes attrs;
try {
attrs = readAttributes();
} catch (IOException e) {
// Failed to get attributes; we don't know the size.
return Optional.absent();
}
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory() || attrs.isSymbolicLink()) {
return Optional.absent();
}
return Optional.of(attrs.size());
}

代码示例来源:origin: apache/nifi

@Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
if (attrs.isDirectory()) {
return FileVisitResult.CONTINUE;
}
final long lastModTime = getLastModTime(file);
if (lastModTime try {
Files.deleteIfExists(file);
containerState.decrementArchiveCount();
LOG.debug("Deleted archived ContentClaim with ID {} from Container {} because it was older than the configured max archival duration",
file.toFile().getName(), containerName);
} catch (final IOException ioe) {
LOG.warn("Failed to remove archived ContentClaim with ID {} from Container {} due to {}", file.toFile().getName(), containerName, ioe.toString());
if (LOG.isDebugEnabled()) {
LOG.warn("", ioe);
}
}
} else if (usableSpace notYetExceedingThreshold.add(new ArchiveInfo(container, file, attrs.size(), lastModTime));
}
return FileVisitResult.CONTINUE;
}
});

代码示例来源:origin: line/armeria

@Override
public HttpFileAttributes readAttributes() throws IOException {
if (!Files.exists(path)) {
return null;
}
try {
final BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
if (attrs.isRegularFile()) {
return new HttpFileAttributes(attrs.size(), attrs.lastModifiedTime().toMillis());
}
} catch (NoSuchFileException e) {
// Non-existent file.
}
return null;
}

代码示例来源:origin: eclipse-vertx/vert.x

public FilePropsImpl(BasicFileAttributes attrs) {
creatiOnTime= attrs.creationTime().toMillis();
lastModifiedTime = attrs.lastModifiedTime().toMillis();
lastAccessTime = attrs.lastAccessTime().toMillis();
isDirectory = attrs.isDirectory();
isOther = attrs.isOther();
isRegularFile = attrs.isRegularFile();
isSymbolicLink = attrs.isSymbolicLink();
size = attrs.size();
}

代码示例来源:origin: spotify/docker-client

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
final Path relativePath = root.relativize(file);
if (exclude(ignoreMatchers, relativePath)) {
return FileVisitResult.CONTINUE;
}
final TarArchiveEntry entry = new TarArchiveEntry(file.toFile());
entry.setName(relativePath.toString());
entry.setMode(getFileMode(file));
entry.setSize(attrs.size());
tarStream.putArchiveEntry(entry);
Files.copy(file, tarStream);
tarStream.closeArchiveEntry();
return FileVisitResult.CONTINUE;
}

代码示例来源:origin: Netflix/Priam

private static FileUploadResult getFileUploadResult(
String keyspaceName, String columnFamilyName, Path file) throws Exception {
BasicFileAttributes fileAttributes = Files.readAttributes(file, BasicFileAttributes.class);
return new FileUploadResult(
file,
keyspaceName,
columnFamilyName,
fileAttributes.lastModifiedTime().toInstant(),
fileAttributes.creationTime().toInstant(),
fileAttributes.size());
}

代码示例来源:origin: prestodb/presto

@Override
public Optional sizeIfKnown() {
BasicFileAttributes attrs;
try {
attrs = readAttributes();
} catch (IOException e) {
// Failed to get attributes; we don't know the size.
return Optional.absent();
}
// Don't return a size for directories or symbolic links; their sizes are implementation
// specific and they can't be read as bytes using the read methods anyway.
if (attrs.isDirectory() || attrs.isSymbolicLink()) {
return Optional.absent();
}
return Optional.of(attrs.size());
}

代码示例来源:origin: apache/nifi

if (minSize > attributes.size()) {
return false;
if (maxSize != null && maxSize return false;

代码示例来源:origin: Graylog2/graylog2-server

/**
* Create a file info for the given path.
*
* @param path the path must exist, otherwise an IllegalArgumentException is thrown
* @return the file info object
*/
@NotNull
public static FileInfo forPath(Path path) {
try {
final BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
return FileInfo.builder()
.path(path)
.key(attributes.fileKey())
.size(attributes.size())
.modificationTime(attributes.lastModifiedTime())
.build();
} catch (Exception e) {
LOG.error("Couldn't get file info for path: {}", path, e);
return EMPTY_FILE_INFO.toBuilder().path(path).build();
}
}

代码示例来源:origin: apache/nifi

.fullPathFileName(file.getAbsolutePath())
.lastModifiedTime(attributes.lastModifiedTime().toMillis())
.size(attributes.size())
.build();

推荐阅读
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 1.如何在运行状态查看源代码?查看函数的源代码,我们通常会使用IDE来完成。比如在PyCharm中,你可以Ctrl+鼠标点击进入函数的源代码。那如果没有IDE呢?当我们想使用一个函 ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • RecyclerView初步学习(一)
    RecyclerView初步学习(一)ReCyclerView提供了一种插件式的编程模式,除了提供ViewHolder缓存模式,还可以自定义动画,分割符,布局样式,相比于传统的ListVi ... [详细]
  • 本文基于刘洪波老师的《英文词根词缀精讲》,深入探讨了多个重要词根词缀的起源及其相关词汇,帮助读者更好地理解和记忆英语单词。 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 数据库内核开发入门 | 搭建研发环境的初步指南
    本课程将带你从零开始,逐步掌握数据库内核开发的基础知识和实践技能,重点介绍如何搭建OceanBase的开发环境。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • XNA 3.0 游戏编程:从 XML 文件加载数据
    本文介绍如何在 XNA 3.0 游戏项目中从 XML 文件加载数据。我们将探讨如何将 XML 数据序列化为二进制文件,并通过内容管道加载到游戏中。此外,还会涉及自定义类型读取器和写入器的实现。 ... [详细]
  • 本章将深入探讨移动 UI 设计的核心原则,帮助开发者构建简洁、高效且用户友好的界面。通过学习设计规则和用户体验优化技巧,您将能够创建出既美观又实用的移动应用。 ... [详细]
  • 本文详细解析了Python中的os和sys模块,介绍了它们的功能、常用方法及其在实际编程中的应用。 ... [详细]
author-avatar
shengxin11
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有