java.nio.file.NoSuchFileException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(237)

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

NoSuchFileException.getMessage介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * This implementation opens a NIO file stream for the underlying file.
 * @see java.io.FileInputStream
 */
@Override
public InputStream getInputStream() throws IOException {
  try {
    return Files.newInputStream(this.filePath);
  }
  catch (NoSuchFileException ex) {
    throw new FileNotFoundException(ex.getMessage());
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * This implementation opens a FileChannel for the underlying file.
 * @see java.nio.channels.FileChannel
 */
@Override
public ReadableByteChannel readableChannel() throws IOException {
  try {
    return FileChannel.open(this.filePath, StandardOpenOption.READ);
  }
  catch (NoSuchFileException ex) {
    throw new FileNotFoundException(ex.getMessage());
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * This implementation opens a Channel for the underlying file.
 * @see Files#newByteChannel(Path, OpenOption...)
 */
@Override
public ReadableByteChannel readableChannel() throws IOException {
  try {
    return Files.newByteChannel(this.path, StandardOpenOption.READ);
  }
  catch (NoSuchFileException ex) {
    throw new FileNotFoundException(ex.getMessage());
  }
}

代码示例来源:origin: org.springframework/spring-core

/**
 * This implementation opens a NIO file stream for the underlying file.
 * @see java.io.FileInputStream
 */
@Override
public InputStream getInputStream() throws IOException {
  try {
    return Files.newInputStream(this.filePath);
  }
  catch (NoSuchFileException ex) {
    throw new FileNotFoundException(ex.getMessage());
  }
}

代码示例来源:origin: org.springframework/spring-core

/**
 * This implementation opens a FileChannel for the underlying file.
 * @see java.nio.channels.FileChannel
 */
@Override
public ReadableByteChannel readableChannel() throws IOException {
  try {
    return FileChannel.open(this.filePath, StandardOpenOption.READ);
  }
  catch (NoSuchFileException ex) {
    throw new FileNotFoundException(ex.getMessage());
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * This implementation returns the underlying File/Path last-modified time.
 */
@Override
public long lastModified() throws IOException {
  if (this.file != null) {
    return super.lastModified();
  }
  else {
    try {
      return Files.getLastModifiedTime(this.filePath).toMillis();
    }
    catch (NoSuchFileException ex) {
      throw new FileNotFoundException(ex.getMessage());
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * This implementation returns the underlying File/Path length.
 */
@Override
public long contentLength() throws IOException {
  if (this.file != null) {
    long length = this.file.length();
    if (length == 0L && !this.file.exists()) {
      throw new FileNotFoundException(getDescription() +
          " cannot be resolved in the file system for checking its content length");
    }
    return length;
  }
  else {
    try {
      return Files.size(this.filePath);
    }
    catch (NoSuchFileException ex) {
      throw new FileNotFoundException(ex.getMessage());
    }
  }
}

代码示例来源:origin: org.springframework/spring-core

/**
 * This implementation opens a Channel for the underlying file.
 * @see Files#newByteChannel(Path, OpenOption...)
 */
@Override
public ReadableByteChannel readableChannel() throws IOException {
  try {
    return Files.newByteChannel(this.path, StandardOpenOption.READ);
  }
  catch (NoSuchFileException ex) {
    throw new FileNotFoundException(ex.getMessage());
  }
}

代码示例来源:origin: org.springframework/spring-core

/**
 * This implementation returns the underlying File/Path last-modified time.
 */
@Override
public long lastModified() throws IOException {
  if (this.file != null) {
    return super.lastModified();
  }
  else {
    try {
      return Files.getLastModifiedTime(this.filePath).toMillis();
    }
    catch (NoSuchFileException ex) {
      throw new FileNotFoundException(ex.getMessage());
    }
  }
}

代码示例来源:origin: org.springframework/spring-core

/**
 * This implementation returns the underlying File/Path length.
 */
@Override
public long contentLength() throws IOException {
  if (this.file != null) {
    long length = this.file.length();
    if (length == 0L && !this.file.exists()) {
      throw new FileNotFoundException(getDescription() +
          " cannot be resolved in the file system for checking its content length");
    }
    return length;
  }
  else {
    try {
      return Files.size(this.filePath);
    }
    catch (NoSuchFileException ex) {
      throw new FileNotFoundException(ex.getMessage());
    }
  }
}

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

private void dump( String database, DatabaseLayout databaseLayout, Path transactionalLogsDirectory, Path archive )
    throws CommandFailed
{
  Path databasePath = databaseLayout.databaseDirectory().toPath();
  try
  {
    File storeLockFile = databaseLayout.getStoreLayout().storeLockFile();
    dumper.dump( databasePath, transactionalLogsDirectory, archive, path -> Objects.equals( path.getFileName().toString(), storeLockFile.getName() ) );
  }
  catch ( FileAlreadyExistsException e )
  {
    throw new CommandFailed( "archive already exists: " + e.getMessage(), e );
  }
  catch ( NoSuchFileException e )
  {
    if ( Paths.get( e.getMessage() ).toAbsolutePath().equals( databasePath ) )
    {
      throw new CommandFailed( "database does not exist: " + database, e );
    }
    wrapIOException( e );
  }
  catch ( IOException e )
  {
    wrapIOException( e );
  }
}

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

if ( Paths.get( e.getMessage() ).toAbsolutePath().equals( archive.toAbsolutePath() ) )

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

return new XnioFileChannel(path.getFileSystem().provider().newFileChannel(path, openOptions));
} catch (NoSuchFileException e) {
  throw new FileNotFoundException(e.getMessage());

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

@Test
void shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryDoesntExist()
{
  Path archive = testDirectory.file( "the-archive.dump" ).toPath();
  Path destination = testDirectory.file( "destination" ).toPath();
  Path txLogsDestination = Paths.get( testDirectory.absolutePath().getAbsolutePath(), "subdir", "txLogs" );
  NoSuchFileException noSuchFileException = assertThrows( NoSuchFileException.class, () -> new Loader().load( archive, destination, txLogsDestination ) );
  assertEquals( txLogsDestination.getParent().toString(), noSuchFileException.getMessage() );
}

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

@Test
void shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryDoesntExist() throws IOException
{
  Path archive = testDirectory.file( "the-archive.dump" ).toPath();
  Path destination = Paths.get( testDirectory.absolutePath().getAbsolutePath(), "subdir", "the-destination" );
  NoSuchFileException noSuchFileException = assertThrows( NoSuchFileException.class, () -> new Loader().load( archive, destination, destination ) );
  assertEquals( destination.getParent().toString(), noSuchFileException.getMessage() );
}

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

inode = getInode(f);
} catch (NoSuchFileException e) {
 logger.info("File has been deleted in the meantime: " + e.getMessage());
 continue;

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

@Test
void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryDoesntExist()
{
  Path directory = testDirectory.directory( "a-directory" ).toPath();
  Path archive = testDirectory.file( "subdir/the-archive.dump" ).toPath();
  NoSuchFileException exception =
      assertThrows( NoSuchFileException.class, () -> new Dumper().dump( directory, directory, archive, Predicates.alwaysFalse() ) );
  assertEquals( archive.getParent().toString(), exception.getMessage() );
}

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

@Test
void shouldGiveAClearErrorMessageIfTheArchiveDoesntExist()
{
  Path archive = testDirectory.file( "the-archive.dump" ).toPath();
  Path destination = testDirectory.file( "the-destination" ).toPath();
  NoSuchFileException exception = assertThrows( NoSuchFileException.class, () -> new Loader().load( archive, destination, destination ) );
  assertEquals( archive.toString(), exception.getMessage() );
}

代码示例来源:origin: blynkkk/blynk-server

log.error("Unable to copy uploaded file to static folder. Reason : {}", e.getMessage());
  response = (serverError());
} catch (Exception e) {

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

@Test
void shouldGiveAClearErrorMessageIfTheDirectoryDoesntExist()
{
  Path directory = testDirectory.file( "a-directory" ).toPath();
  Path archive = testDirectory.file( "the-archive.dump" ).toPath();
  NoSuchFileException exception =
      assertThrows( NoSuchFileException.class, () -> new Dumper().dump( directory, directory, archive, Predicates.alwaysFalse() ) );
  assertEquals( directory.toString(), exception.getMessage() );
}

相关文章