$darkmode
DENOPTIM
denoptim.files.FileUtils Class Reference

Static Public Member Functions

static void addToRecentFiles (String fileName, FileFormat ff)
 Appends an entry to the list of recent files. More...
 
static void addToRecentFiles (File file, FileFormat ff)
 Appends an entry to the list of recent files. More...
 
static boolean isLineInTxtFile (String query, File file, boolean add) throws IOException
 Search in a file for a line matching the given string query. More...
 
static boolean canWriteAndReadTo (String pathName)
 Check whether we can write and read to a given pathname. More...
 
static String getTempFolder ()
 Looks for a writable location where to put temporary files and returns an absolute pathname to the folder where tmp files can be created. More...
 
static boolean createDirectory (String fileName)
 Creates a directory. More...
 
static boolean checkExists (String fileName)
 
static void deleteFile (String fileName) throws DENOPTIMException
 Delete the file. More...
 
static void deleteFilesContaining (String path, String pattern) throws DENOPTIMException
 Delete all files with pathname containing a given string. More...
 
static int countLinesInFile (String fileName) throws DENOPTIMException
 Count the number of lines in the file. More...
 
static void createZipFile (String zipOutputFileName, String[] filesToZip) throws Exception
 Creates a zip file. More...
 
static FileFormat detectFileFormat (File inFile) throws UndetectedFileFormatException, IOException
 Inspects a file/folder and tries to detect if there is one of the data sources that is recognized by DENOPTIM. More...
 
static FileFormat detectKindOfJSONFile (String fileName) throws IOException
 Detect the content of a json file. More...
 
static FileFormat detectKindOfSDFFile (String fileName) throws IOException
 Looks into a text file and tries to understand if the file is a collection of parameters for any specific DENOPTIM module. More...
 
static FileFormat detectKindOfParameterFile (String fileName) throws IOException
 Looks into a text file and tries to understand if the file is a collection of parameters for any specific DENOPTIM module. More...
 
static FileFormat detectKindOfTXTFile (String fileName) throws IOException
 Looks into a text file and tries to understand if the file is a known text file. More...
 
static FileFormat detectKindFile (String fileName, FileFormat[] ffs) throws IOException
 Looks into a text file and tries to understand what format it is among the given formats. More...
 
static File getAvailableFileName (File parent, String baseName) throws DENOPTIMException
 Define a filename that can be used, i.e., is still available, because no other file with the same pathname exists. More...
 
static void mergeIntoOneFile (String destinationPathname, List< String > sourcePathnames) throws IOException
 Copies the content of all the files specified in the list of sources and places it into the destination file. More...
 

Detailed Description

Definition at line 57 of file FileUtils.java.

Member Function Documentation

◆ addToRecentFiles() [1/2]

static void denoptim.files.FileUtils.addToRecentFiles ( File  file,
FileFormat  ff 
)
static

Appends an entry to the list of recent files.

If the current list is reaching the max length, then this method will append the new entry and remove the oldest one.

Parameters
filethe file to record.
ffthe declared format of file.

Definition at line 81 of file FileUtils.java.

References denoptim.logging.StaticLogger.appLogger, denoptim.constants.DENOPTIMConstants.EOL, denoptim.io.DenoptimIO.readRecentFilesMap(), denoptim.constants.DENOPTIMConstants.RECENTFILESLIST, and denoptim.io.DenoptimIO.writeData().

Here is the call graph for this function:

◆ addToRecentFiles() [2/2]

static void denoptim.files.FileUtils.addToRecentFiles ( String  fileName,
FileFormat  ff 
)
static

Appends an entry to the list of recent files.

Parameters
fileNamethe file to record.
ffthe declared format of file.

Definition at line 67 of file FileUtils.java.

References denoptim.files.FileUtils.addToRecentFiles().

Referenced by denoptim.files.FileUtils.addToRecentFiles(), denoptim.programs.combinatorial.CEBLParameters.createWorkingDirectory(), denoptim.programs.fragmenter.FragmenterParameters.createWorkingDirectory(), denoptim.gui.CuttingRulesSelectionDialog.CuttingRulesSelectionDialog(), denoptim.gui.GUICompatibilityMatrixTab.initialize(), denoptim.gui.GUIGraphHandler.initialize(), denoptim.gui.GUIPrepare.initialize(), denoptim.gui.GUIVertexInspector.initialize(), denoptim.task.ProgramTask.printErrorToFile(), and denoptim.programs.fitnessevaluator.FRParameters.processParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ canWriteAndReadTo()

static boolean denoptim.files.FileUtils.canWriteAndReadTo ( String  pathName)
static

Check whether we can write and read to a given pathname.

Parameters
pathName
Returns
true if we can write and read in that pathname

Definition at line 185 of file FileUtils.java.

References denoptim.io.DenoptimIO.readList(), and denoptim.io.DenoptimIO.writeData().

Referenced by denoptim.gui.Utils.getTempFile(), denoptim.files.FileUtils.getTempFolder(), and denoptim.gui.GUIPreferencesDialog.pathMustBeReadableWritable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkExists()

◆ countLinesInFile()

static int denoptim.files.FileUtils.countLinesInFile ( String  fileName) throws DENOPTIMException
static

Count the number of lines in the file.

Parameters
fileName
Returns
number of lines in the file
Exceptions
DENOPTIMException

Definition at line 312 of file FileUtils.java.

◆ createDirectory()

static boolean denoptim.files.FileUtils.createDirectory ( String  fileName)
static

◆ createZipFile()

static void denoptim.files.FileUtils.createZipFile ( String  zipOutputFileName,
String[]  filesToZip 
) throws Exception
static

Creates a zip file.

Parameters
zipOutputFileName
filesToZip
Exceptions
Exception

Definition at line 349 of file FileUtils.java.

◆ deleteFile()

static void denoptim.files.FileUtils.deleteFile ( String  fileName) throws DENOPTIMException
static

◆ deleteFilesContaining()

static void denoptim.files.FileUtils.deleteFilesContaining ( String  path,
String  pattern 
) throws DENOPTIMException
static

Delete all files with pathname containing a given string.

Parameters
path
pattern
Exceptions
DENOPTIMException

Definition at line 289 of file FileUtils.java.

References denoptim.files.FileUtils.deleteFile().

Referenced by denoptim.molecularmodeling.RingClosureTool.attemptRingClosure(), and denoptim.integration.tinker.ConformationalSearchPSSROT.performPSSROT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ detectFileFormat()

static FileFormat denoptim.files.FileUtils.detectFileFormat ( File  inFile) throws UndetectedFileFormatException, IOException
static

Inspects a file/folder and tries to detect if there is one of the data sources that is recognized by DENOPTIM.

Parameters
inFilethe file to inspect
Returns
a string informing on the detected file format, or null.
Exceptions
UndetectedFileFormatExceptionwhen the format of the file could not be detected.
IOExceptionwhen the the file could not be read properly.

Definition at line 399 of file FileUtils.java.

References denoptim.files.FileUtils.detectKindOfJSONFile(), denoptim.files.FileUtils.detectKindOfParameterFile(), denoptim.files.FileUtils.detectKindOfSDFFile(), denoptim.files.FileUtils.detectKindOfTXTFile(), denoptim.files.FileFormat.FSE_RUN, denoptim.constants.DENOPTIMConstants.FSEIDXNAMEROOT, denoptim.files.FileFormat.GA_RUN, denoptim.constants.DENOPTIMConstants.GAGENDIRNAMEROOT, and denoptim.files.FileFormat.getExtension().

Referenced by denoptim.gui.GUIGraphHandler.appendGraphsFromFile(), denoptim.main.Main.ensureFileExistsAndIsReadable(), denoptim.gui.GUIGraphHandler.importGraphsFromFile(), denoptim.gui.MainToolBar.initialize(), denoptim.io.DenoptimIO.readDENOPTIMData(), denoptim.io.DenoptimIO.readDENOPTIMGraphsFromFile(), denoptim.io.DenoptimIO.readVertexes(), denoptim.gui.GUI.run(), and denoptim.io.DenoptimIOTest.testDetectFileFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ detectKindFile()

static FileFormat denoptim.files.FileUtils.detectKindFile ( String  fileName,
FileFormat[]  ffs 
) throws IOException
static

Looks into a text file and tries to understand what format it is among the given formats.

Parameters
fileNameThe pathname of the file to analyze.
ffsthe file formats to consider.
Returns
a format of parameters, or null.
Exceptions
Exceptionwhen something goes wrong handling the file

Definition at line 605 of file FileUtils.java.

Referenced by denoptim.files.FileUtils.detectKindOfParameterFile(), denoptim.files.FileUtils.detectKindOfSDFFile(), and denoptim.files.FileUtils.detectKindOfTXTFile().

Here is the caller graph for this function:

◆ detectKindOfJSONFile()

static FileFormat denoptim.files.FileUtils.detectKindOfJSONFile ( String  fileName) throws IOException
static

Detect the content of a json file.

Parameters
fileNamefile to analyze.
Returns
the format of that file or null.
Exceptions
IOException

Definition at line 488 of file FileUtils.java.

References denoptim.json.DENOPTIMgson.getReader(), denoptim.files.FileFormat.GRAPHJSON, and denoptim.files.FileFormat.VRTXJSON.

Referenced by denoptim.files.FileUtils.detectFileFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ detectKindOfParameterFile()

static FileFormat denoptim.files.FileUtils.detectKindOfParameterFile ( String  fileName) throws IOException
static

Looks into a text file and tries to understand if the file is a collection of parameters for any specific DENOPTIM module.

Parameters
fileNameThe pathname of the file to analyze
Returns
a the format of the parameter file or null.
Exceptions
IOException
Exception

Definition at line 570 of file FileUtils.java.

References denoptim.files.FileUtils.detectKindFile(), and denoptim.files.FileFormat.getParameterFormats().

Referenced by denoptim.files.FileUtils.detectFileFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ detectKindOfSDFFile()

static FileFormat denoptim.files.FileUtils.detectKindOfSDFFile ( String  fileName) throws IOException
static

Looks into a text file and tries to understand if the file is a collection of parameters for any specific DENOPTIM module.

Parameters
fileNameThe pathname of the file to analyze
Returns
a string that defined the kind of parameters
Exceptions
IOException
Exception

Definition at line 554 of file FileUtils.java.

References denoptim.files.FileUtils.detectKindFile(), and denoptim.files.FileFormat.getSDFFormats().

Referenced by denoptim.files.FileUtils.detectFileFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ detectKindOfTXTFile()

static FileFormat denoptim.files.FileUtils.detectKindOfTXTFile ( String  fileName) throws IOException
static

Looks into a text file and tries to understand if the file is a known text file.

Note that parameters file, which are in fact text files, are not detected here ad they are treated by the dedicated method FileUtils#detectKindOfParameterFile(String).

Parameters
fileNameThe pathname of the file to analyze
Returns
a the format of the text file or null.
Exceptions
IOException
Exception

Definition at line 588 of file FileUtils.java.

References denoptim.files.FileUtils.detectKindFile(), and denoptim.files.FileFormat.getTXTFormats().

Referenced by denoptim.files.FileUtils.detectFileFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAvailableFileName()

static File denoptim.files.FileUtils.getAvailableFileName ( File  parent,
String  baseName 
) throws DENOPTIMException
static

Define a filename that can be used, i.e., is still available, because no other file with the same pathname exists.

This method returns a string like File_3 when files File, File_1, and File_2 exist already.

Parameters
parentthe folder where the file is meant to be.
baseNamethe prefix of the filename. This string will be postponed by an integer number to identify an available filename.
Returns
the available filename.
Exceptions
DENOPTIMException

Definition at line 729 of file FileUtils.java.

References denoptim.files.FileUtils.createDirectory(), and denoptim.io.DenoptimIO.FS.

Referenced by denoptim.gui.CuttingRulesSelectionDialog.getTmpFileForCuttingRules(), and denoptim.gui.GUIPrepare.prepareWorkSpace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTempFolder()

static String denoptim.files.FileUtils.getTempFolder ( )
static

Looks for a writable location where to put temporary files and returns an absolute pathname to the folder where tmp files can be created.

Returns
a writable absolute path

Definition at line 204 of file FileUtils.java.

References denoptim.files.FileUtils.canWriteAndReadTo().

Referenced by denoptim.gui.Utils.getTempFile(), denoptim.io.DenoptimIO.readAllAtomContainers(), and denoptim.io.DenoptimIOTest.testReadAllAPClasses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isLineInTxtFile()

static boolean denoptim.files.FileUtils.isLineInTxtFile ( String  query,
File  file,
boolean  add 
) throws IOException
static

Search in a file for a line matching the given string query.

If the query is not found in the file, then it is added to it. Note that the query is compared in a case insensitive manner, and ignoring heading/trailing spaces, and with the content of each line in the file, so this is rather slow.

Parameters
querythe string to search for and possibly add to the file.
filethe text file to analyze.
addif true then we add the query if it was not found.
Returns
true is the query was found in the file. Note that when add is true we return false when the match is not found in the file, but the moment we return the file has been already updated by this method as to add the query. So, independently on the return value, the file will contain the query string when this method returns.
Exceptions
IOExceptionwhen handling of the memory written on disk returns exception.

Definition at line 132 of file FileUtils.java.

References denoptim.io.DenoptimIO.NL.

Referenced by denoptim.utils.SizeControlledSet.addNewUniqueEntry(), and denoptim.utils.SizeControlledSet.contains().

Here is the caller graph for this function:

◆ mergeIntoOneFile()

static void denoptim.files.FileUtils.mergeIntoOneFile ( String  destinationPathname,
List< String >  sourcePathnames 
) throws IOException
static

Copies the content of all the files specified in the list of sources and places it into the destination file.

Parameters
destinationPathnamethe destination of all content.
sourcePathnamesthe pathnames of the files to be copied into the destination file.
Exceptions
IOException

Definition at line 768 of file FileUtils.java.

Referenced by denoptim.gui.GUIInspectGARun.initialize().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: