org.scijava.util.FileUtils.limitPath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(128)

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

FileUtils.limitPath介绍

[英]Compacts a path into a given number of characters. The result is similar to the Win32 API PathCompactPathExA.
[中]将路径压缩为给定数量的字符。结果与Win32 API PathCompactPathExA类似。

代码示例

代码示例来源:origin: org.scijava/scijava-common

/** Shortens the given path to ensure it conforms to a maximum length. */
private String shortPath(final String path) {
  // TODO - shorten path name as needed
  return FileUtils.limitPath(path, MAX_DISPLAY_LENGTH);
}

代码示例来源:origin: scijava/scijava-common

/** Shortens the given path to ensure it conforms to a maximum length. */
private String shortPath(final String path) {
  // TODO - shorten path name as needed
  return FileUtils.limitPath(path, MAX_DISPLAY_LENGTH);
}

代码示例来源:origin: scijava/scijava-common

@Test
public void testLimitPath() {
  assertEquals("C:\\Doc...SC Info.txt",
    FileUtils
      .limitPath("C:\\Documents and Settings\\All Users\\"
        + "Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt",
        20));
  assertEquals("C:\\temp", FileUtils.limitPath("C:\\temp", 20));
  assertEquals("C:\\1\\2\\3\\...test.txt", FileUtils.limitPath(
    "C:\\1\\2\\3\\4\\5\\test.txt", 20));
  assertEquals("...testfile.txt", FileUtils.limitPath("C:/1/2/testfile.txt",
    15));
  assertEquals("C:/1...test.txt", FileUtils.limitPath(
    "C:/1/2/3/4/5/test.txt", 15));
  assertEquals("\\\\server\\p1\\p2\\...p6", FileUtils.limitPath(
    "\\\\server\\p1\\p2\\p3\\p4\\p5\\p6", 20));
  assertEquals("http://www...pb.html", FileUtils.limitPath(
    "http://www.rgagnon.com/p1/p2/p3/p4/p5/pb.html", 20));
}

相关文章