Class Abacus

java.lang.Object
it.ramecera.salad.file.Abacus

public class Abacus
extends java.lang.Object

Class for various operations on files.

Company: Rameceraâ„¢
Creation date: 2020-04-09
Last updated: 2020-09-15

Changes:
2020-04-09: inserted method: public static void estraiFiltroZip (final String fileZipOut, File destDir, final String filter)

Author:
M. Maglioni *
  • Constructor Summary

    Constructors 
    Constructor Description
    Abacus()  
  • Method Summary

    Modifier and Type Method Description
    static void buildDirectory​(java.io.File cradle)
    Overload of the preceding method.
    static void buildDirectory​(java.lang.String path)
    Create a directory, if it doesn't already exist, after making sure it isn't a file.
    It can only create one directory at a time.
    Example: I have to create directory b in path C:/a;
    I must put the string: "C:/a/b" as the argument of the method, and I must first verify that C:/a exists.
    static void buildDirectoryCompletely​(java.lang.String path, java.lang.String separator)
    Create a complete path, that is, make a succession of directories creations.
    static int contaFile​(java.lang.String x, java.lang.String y)
    Count of files in a directory, filtered according to a pattern.
    static void copyDirectoryRecursion​(java.io.File inputFile, java.io.File outputFile, boolean replace)
    Creation date: 2020-09-08
    Last updated: 2020-09-15
    Class: Abacus
    static void copyDirectoryRecursion​(java.nio.file.Path inPath, java.nio.file.Path outPath, boolean replace)
    Creation date: 2020-09-08
    Last updated: 2020-09-15
    Class: Abacus
    static void copyDirectoryRecursion​(java.nio.file.Path inPath, java.nio.file.Path outPath, boolean replace, java.nio.file.LinkOption[] nfl)
    Creation date: 2020-09-08
    Last updated: 2020-09-15
    Class: Abacus
    static void copyFile​(java.io.File in, java.io.File out)
    Physical copy of one file on another; overload of the previous one.
    static void copyFile​(java.io.File in, java.io.File out, int max)
    Physical copy of one file to another, declaring a maximum length.
    static void costruisciDirectoryCompleta​(java.lang.String path)
    Create a complete path, that is, make a succession of directories creations.
    static void deleteDirectoryRecursion​(java.io.File file)
    Creation date: 2020-09-08
    Last updated: 2020-09-15
    Class: Abacus
    static void deleteDirectoryRecursion​(java.nio.file.Path path)
    Creation date: 2020-09-15
    Class: Abacus
    static void deleteDirectoryRecursion​(java.nio.file.Path path, java.nio.file.LinkOption[] nfl)
    Creation date: 2020-09-15
    Class: Abacus
    static void destroyDirectory​(java.lang.String y)
    Deletion of files from a directory and all its subdirectories, at all depths.
    static int eraseFiles​(java.lang.String pattern, java.lang.String y)
    Deleting the files of a directory, filtered according to a pattern.
    static void extractAllFromZip​(java.lang.String fileZipInput, java.io.File destDir)
    Creation date: 2020-05-19
    Last updated: 2020-05-19
    Class: Abacus
    static void extractFromZipFilter​(java.lang.String fileZipInput, java.io.File destDir, java.lang.String filter, java.lang.String except)
    Creation date: 2020-05-19
    Last updated: 2020-09-14
    Class: Abacus
    static long ilPiuGiovaneFile_A​(java.lang.String x, java.lang.String y)
    Find the most recent file among those present in a directory, filtered according to a pattern.
    static java.util.Calendar ilPiuGiovaneFile_B​(java.lang.String x, java.lang.String y)
    Find the most recent file among those present in a directory, filtered according to a pattern.
    static void mergeFile​(java.lang.String i0, java.lang.String i1, java.lang.String o)
    Physical copy of two files, queued, on another; an LF is placed between the two.
    static java.lang.String senzaExtension​(java.lang.String s)
    Deprecated.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • destroyDirectory

      public static void destroyDirectory​(java.lang.String y) throws ExactException

      Deletion of files from a directory and all its subdirectories, at all depths. Eventually the path remains but is empty.

      Creation date: 2020-04-09
      Last updated: 2020-06-03

      Changes:

      Parameters:
      y - the path to be demolished
      Throws:
      ExactException - error in the parameters provided
    • eraseFiles

      public static int eraseFiles​(java.lang.String pattern, java.lang.String y) throws ExactException

      Deleting the files of a directory, filtered according to a pattern.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:

      Parameters:
      pattern - the pattern to filter the files, according to the codes of the class java.util.regex.Pattern.
      y - the path where to look for the files
      Returns:
      quantity of deleted files
      Throws:
      ExactException - error code in the provided parameters
    • ilPiuGiovaneFile_A

      public static long ilPiuGiovaneFile_A​(java.lang.String x, java.lang.String y)

      Find the most recent file among those present in a directory, filtered according to a pattern.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:
      21/01 / 09: eliminated the milliseconds from the final result.

      Parameters:
      x - the pattern to filter the files, according to the codes of the java.util class. regex.Pattern.
      y - the directory to search for files
      Returns:
      the most recent modification date, expressed as long number
      Since:
      SVutensiliJ4_1.2.2, class 1.1.0
    • ilPiuGiovaneFile_B

      public static java.util.Calendar ilPiuGiovaneFile_B​(java.lang.String x, java.lang.String y)

      Find the most recent file among those present in a directory, filtered according to a pattern. It is returned not the name of the file, but its modification date, expressed as a Calendar object.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:
      21/01 / 09: milliseconds removed from the final result.

      Parameters:
      x - the pattern to filter the files, according to the codes of the class java.util.regex.Pattern.
      y - the directory to search for files
      Returns:
      the most recent modification date, expressed as a Calendar object; returns the date 2020-04-09 if the directory is empty
      Since:
      SVutensiliJ4_1.2.2, class 1.1.0
    • contaFile

      public static int contaFile​(java.lang.String x, java.lang.String y)

      Count of files in a directory, filtered according to a pattern.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:

      Parameters:
      x - the pattern to filter the files, according to the codes of the class java.util.regex.Pattern.
      y - path where to search for files
      Returns:
      quantity of files found
      See Also:
      "prog. bigExport_2.0.0, class ExportSchema_1"
    • copyFile

      public static void copyFile​(java.io.File in, java.io.File out, int max) throws java.lang.Exception

      Physical copy of one file to another, declaring a maximum length.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:
      20/05 08: sets the condition that the file does not already exist identically
      2020-04-09: elimination of the preventive cancellation because it is useless
      2020-04-09: reintroduced the delete estimate

      Parameters:
      in - file in unput
      out - file in output
      max - maximum file length
      Throws:
      java.lang.Exception - ordinary exception
    • copyFile

      public static void copyFile​(java.io.File in, java.io.File out) throws java.io.IOException

      Physical copy of one file on another; overload of the previous one. It differs from the previous one because there is no need to declare the maximum length.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:
      2013-08- 07: added the instruction setting the last modification date of the output file

      Parameters:
      in - file in unput
      out - file in output
      Throws:
      java.io.IOException - standard exception
    • mergeFile

      public static void mergeFile​(java.lang.String i0, java.lang.String i1, java.lang.String o) throws java.lang.Exception

      Physical copy of two files, queued, on another; an LF is placed between the two.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:

      Parameters:
      i0 - file in unput
      i1 - file in unput
      o - file in output
      Throws:
      java.lang.Exception - ordinary exception
    • buildDirectory

      public static void buildDirectory​(java.lang.String path)

      Create a directory, if it doesn't already exist, after making sure it isn't a file.
      It can only create one directory at a time.
      Example: I have to create directory b in path C:/a;
      I must put the string: "C:/a/b" as the argument of the method, and I must first verify that C:/a exists.

      Creation date: 2020-09-03
      Last updated: 2020-09-03

      Modifications:

      Parameters:
      path - to the directory to be built, complete with path
    • buildDirectory

      public static void buildDirectory​(java.io.File cradle)

      Overload of the preceding method.

      Creation date: 2020-09-03
      Last updated: 2020-09-03

      Modifications:

      Parameters:
      cradle - directory to be created
    • costruisciDirectoryCompleta

      public static void costruisciDirectoryCompleta​(java.lang.String path)

      Create a complete path, that is, make a succession of directories creations.

      Creation date: 2020-04-09
      Last updated: 2020-04-09
      Author: M. Maglioni

      Changes :

      Parameters:
      path - the directory to be built, complete with path
    • buildDirectoryCompletely

      public static void buildDirectoryCompletely​(java.lang.String path, java.lang.String separator)

      Create a complete path, that is, make a succession of directories creations.

      Creation date: 2020-04-09
      Last updated: 2020-04-09
      Author: M. Maglioni

      Changes :

      Parameters:
      path - the directory to be built, complete with path
      separator - the separator (slash or backslash) inside the name of a path
    • senzaExtension

      @Deprecated public static java.lang.String senzaExtension​(java.lang.String s)
      Deprecated.

      Removing the extension from a file name. Deprecated on 2020-04-09 because it is not exact: if the file has no extension, and is preceded by a directory name containing a dot, it gives an incorrect result. The correct method to use is Mix.estraiExtension.

      Creation date: 2020-04-09
      Last updated: 2020-04-09

      Changes:

      Parameters:
      s - the name of the complete file
      Returns:
      the name of the file without extension (nor dot, of course)
    • extractAllFromZip

      public static void extractAllFromZip​(java.lang.String fileZipInput, java.io.File destDir) throws java.io.FileNotFoundException, java.io.IOException

      Creation date: 2020-05-19
      Last updated: 2020-05-19
      Class: Abacus

      Parameters:
      fileZipInput - name of the input file
      destDir - output directory
      Throws:
      java.io.FileNotFoundException - obvious
      java.io.IOException - obvious
    • extractFromZipFilter

      public static void extractFromZipFilter​(java.lang.String fileZipInput, java.io.File destDir, java.lang.String filter, java.lang.String except) throws java.io.FileNotFoundException, java.io.IOException

      Creation date: 2020-05-19
      Last updated: 2020-09-14
      Class: Abacus

      Parameters:
      fileZipInput - name of the input file
      destDir - output directory
      filter - obvious
      except - I don't have to copy the "dummy.txt" files, because they were added to the jar only to allow the creation of some empty directories.
      Throws:
      java.io.FileNotFoundException - obvious
      java.io.IOException - obvious
    • deleteDirectoryRecursion

      public static final void deleteDirectoryRecursion​(java.nio.file.Path path) throws java.io.IOException

      Creation date: 2020-09-15
      Class: Abacus

      Description: delete a directory, with all its content.

      Parameters:
      path - object to delete
      Throws:
      java.io.IOException - ordinary exception
    • deleteDirectoryRecursion

      public static final void deleteDirectoryRecursion​(java.nio.file.Path path, java.nio.file.LinkOption[] nfl) throws java.io.IOException

      Creation date: 2020-09-15
      Class: Abacus

      Description: delete a directory, with all its content.

      Parameters:
      path - object to delete
      nfl - link options
      Throws:
      java.io.IOException - ordinary exception
    • copyDirectoryRecursion

      public static final void copyDirectoryRecursion​(java.nio.file.Path inPath, java.nio.file.Path outPath, boolean replace) throws java.io.IOException

      Creation date: 2020-09-08
      Last updated: 2020-09-15
      Class: Abacus

      Description: copy all content of a directory.

      Parameters:
      inPath - input object
      outPath - output object
      replace - replace-existing optio
      Throws:
      java.io.IOException - ordinary exception
    • copyDirectoryRecursion

      public static final void copyDirectoryRecursion​(java.nio.file.Path inPath, java.nio.file.Path outPath, boolean replace, java.nio.file.LinkOption[] nfl) throws java.io.IOException

      Creation date: 2020-09-08
      Last updated: 2020-09-15
      Class: Abacus

      Description: copy all content of a directory.

      Parameters:
      inPath - input object
      outPath - output object
      replace - replace-existing option
      nfl - link options
      Throws:
      java.io.IOException - ordinary exception
    • deleteDirectoryRecursion

      public static final void deleteDirectoryRecursion​(java.io.File file) throws java.io.IOException

      Creation date: 2020-09-08
      Last updated: 2020-09-15
      Class: Abacus

      Description: delete a directory, with all its content; overloading of the preceding one.

      Parameters:
      file - object to delete
      Throws:
      java.io.IOException - ordinary exception
    • copyDirectoryRecursion

      public static final void copyDirectoryRecursion​(java.io.File inputFile, java.io.File outputFile, boolean replace) throws java.io.IOException

      Creation date: 2020-09-08
      Last updated: 2020-09-15
      Class: Abacus

      Description: copy a directory, with all its content; overloading of the preceding one.

      Parameters:
      inputFile - input object
      outputFile - output object
      replace - replace-existing option
      Throws:
      java.io.IOException - standard exception