Module id.xfunction

Class XPaths

Object
XPaths

public class XPaths extends Object
Additions to standard java.nio.file.Paths
  • Constructor Details

    • XPaths

      public XPaths()
  • Method Details

    • splitFileName

      public static String[] splitFileName(String fileName)
      Usually extension of the file is part of its file name. This function splits file name on two-value array:
      array[0] = file name (without extension)
       array[1] = file extension (or null if extension is absent)
       

      If filename starts with '.' it means it has no extension.

    • appendToFileName

      public static Path appendToFileName(Path path, String postfix)
      Append postfix into file name.

      Postfix is appended to the file name excluding its extension:

      
       appendToFileName(Paths.get("/tmp/a.png"), "-cropped")
       
      Will produce: "/tmp/a-cropped.png"
    • appendToFullFileName

      public static Path appendToFullFileName(Path path, String postfix)
      Append postfix into full file name.

      Postfix is appended to the file name including its extension:

      
       appendToFullFileName(Paths.get("/tmp/a.png"), "-cropped")
       
      Will produce: "/tmp/a.png-cropped"