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

x33g5p2x  于2022-01-25 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(132)

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

Path.compareTo介绍

暂无

代码示例

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

@Override
public int compareTo(Path other) {
  return delegate.compareTo(other);
}

代码示例来源:origin: mpatric/mp3agic

public void save(String newFilename) throws IOException, NotSupportedException {
  if (path.toAbsolutePath().compareTo(Paths.get(newFilename).toAbsolutePath()) == 0) {
    throw new IllegalArgumentException("Save filename same as source filename");
  }
  try (SeekableByteChannel saveFile = Files.newByteChannel(Paths.get(newFilename), EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE))) {
    if (hasId3v2Tag()) {
      ByteBuffer byteBuffer = ByteBuffer.wrap(id3v2Tag.toBytes());
      byteBuffer.rewind();
      saveFile.write(byteBuffer);
    }
    saveMpegFrames(saveFile);
    if (hasCustomTag()) {
      ByteBuffer byteBuffer = ByteBuffer.wrap(customTag);
      byteBuffer.rewind();
      saveFile.write(byteBuffer);
    }
    if (hasId3v1Tag()) {
      ByteBuffer byteBuffer = ByteBuffer.wrap(id3v1Tag.toBytes());
      byteBuffer.rewind();
      saveFile.write(byteBuffer);
    }
    saveFile.close();
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

compare = 1;
} else {
  compare = children[child].file.compareTo(files[file]);

代码示例来源:origin: org.codehaus.groovy/groovy-nio

@Override
public int compareTo(Path other) {
  return delegate.compareTo(other);
}

代码示例来源:origin: com.google.errorprone/javac-shaded

@Override
  public int compare(Path f1, Path f2) {
    return -f1.getFileName().compareTo(f2.getFileName());
  }
}

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

/**
* returns true if the Path is a Windows Junction
*/
private static boolean isJunction(Path p) {
  boolean isJunction = false;
  try {
    isJunction = (p.compareTo(p.toRealPath()) != 0);
  } catch (IOException e) {
    e.printStackTrace(); // TODO: handleMeProperly
  }
  return isJunction;
}

代码示例来源:origin: br.com.objectos/io-fs

@Override
public int compareTo(Node o) {
 int nameCount = Integer.compare(delegate.getNameCount(), o.delegate.getNameCount());
 if (nameCount != 0) {
  return nameCount;
 }
 return delegate.compareTo(o.delegate);
}

代码示例来源:origin: br.com.objectos.io/fs

@Override
public int compareTo(Node o) {
 int nameCount = Integer.compare(delegate.getNameCount(), o.delegate.getNameCount());
 if (nameCount != 0) {
  return nameCount;
 }
 return delegate.compareTo(o.delegate);
}

代码示例来源:origin: br.com.objectos.core/io

@Override
public int compareTo(Node o) {
 int nameCount = Integer.compare(delegate.getNameCount(), o.delegate.getNameCount());
 if (nameCount != 0) {
  return nameCount;
 }
 return delegate.compareTo(o.delegate);
}

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

Map<Path, List<String>> readFiles = new TreeMap<>(new Comparator<Path>() {
  @Override
  public int compare(Path o1, Path o2) {
    Matcher o1Matcher = NUMBER_PATTERN.matcher(o1.getFileName().toString());
    Matcher o2Matcher = NUMBER_PATTERN.matcher(o2.getFileName().toString());
    if (o1Matcher.find() && o2Matcher.find()) {
      return Integer.compare(Integer.parseInt(o1Matcher.group()), Integer.parseInt(o2Matcher.group()));
    } else {
      return o1.compareTo(o2);
    }
  }
});

代码示例来源:origin: vivo-project/Vitro

@Override
public int compare(PathPieces p1, PathPieces p2) {
  int scoring = searchFor.score(p1) - searchFor.score(p2);
  if (scoring != 0) {
    return scoring; // prefer matches to region and language
  }
  int pathLength = p1.path.getNameCount() - p2.path.getNameCount();
  if (pathLength != 0) {
    return -pathLength; // shorter is better
  }
  return -p1.path.compareTo(p2.path); // early in alphabet is better
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( NotDefaultFileSystem.class )
public void testCompareToDifferentProviderThrows() throws Exception {
  assertThatThrownBy( () -> relABC().compareTo( FileSystems.getDefault().getPath( nameA() ) ) ).isInstanceOf( ClassCastException.class );
}

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

@Override
public int compareTo(MediaFile mf2) {
 return this.getFileAsPath().compareTo(mf2.getFileAsPath());
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
public void testCompareToOfEqualPathsIs0() throws Exception {
  assertThat( relABC().compareTo( relABC() ) ).isEqualTo( 0 );
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { SecondFileSystem.class } )
public void testCompareToDifferentFSPathSameToStringButDifferent() throws IOException {
  assertThat( absAB().toString().compareTo( otherFSAbsAB().toString() ) ).isEqualTo( 0 );
  assertThat( absAB().compareTo( otherFSAbsAB() )).isNotEqualTo( 0 );
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { Unix.class } )
public void testDefaultPathIsSmallerThanAbsolute() {
  assertThat( pathDefault().compareTo( absAB() ) ).isLessThan( 0 );
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { Unix.class } )
public void testDefaultPathIsSmallerThanRelative() {
  assertThat( pathDefault().compareTo( relAB() ) ).isLessThan( 0 );
}

代码示例来源:origin: com.io7m.jwhere/io7m-jwhere-core

@Override
 default int compareTo(final @Nullable CatalogVerificationReportItemType o)
 {
  return this.getPath().compareTo(NullCheck.notNull(o).getPath());
 }
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( Windows.class )
public void testCaseIgnorantPathKeepCompareSaneSmaller() throws IOException {
  assertThat( absAB().compareTo( mixCase( absABC()))).isLessThan( 0 );
}

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

@Test
public void compareToGreaterValue() {
  final Path path = fileSystem.getPath("/toplevel/a");
  final String otherName = "/toplevel/b";
  final Path other = fileSystem.getPath(otherName);
  final int compare = path.compareTo(other);
  Assert.assertEquals(-1, compare);
}

相关文章