private void logAppHeader() { System.out.flush(); System.out.println("------------------------------------------------------------"); System.out.println("\ud83d\udd25 " + ansi().bold() + " " + provideProductName() + ansi().boldOff() + " " + provideProductVersion() + " - Command Line Tool"); System.out.println("------------------------------------------------------------"); System.out.println("Process ID : " + ManagementFactory.getRuntimeMXBean().getName()); System.out.println("Max configured JVM memory (Xmx) : " + FileHelper.getFileSizeDisplay(Runtime.getRuntime().maxMemory(), 1)); System.out.println("Detected Java version : " + System.getProperty("java.version")); System.out.println("------------------------------------------------------------"); }
@Nullable public String getNameSecure () { return FilenameHelper.getAsSecureValidFilename (m_sName); }
/** * @param aDumpFile * The file to dump to. */ public HTTPOutgoingDumperFileBased (@Nonnull final File aDumpFile) { super (FileHelper.getBufferedOutputStream (aDumpFile)); m_aDumpFile = aDumpFile; }
/** * Deletes the underlying storage for a file item, including deleting any * associated temporary disk file. Although this storage will be deleted * automatically when the <code>FileItem</code> instance is garbage collected, * this method can be used to ensure that this is done at an earlier time, * thus preserving system resources. */ public void delete () { m_aCachedContent = null; final File aTempFile = getStoreLocation (); if (aTempFile != null) { final FileIOError aIOError = FileOperations.deleteFileIfExisting (aTempFile); if (aIOError.isFailure ()) if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete temporary file " + aTempFile + " with error " + aIOError.toString ()); } }
@Nonnull private static FileIOError _deleteUDO (@Nonnull final TemporaryUserDataObject aUDO) { LOGGER.info ("Deleting uploaded file " + aUDO); final FileIOError aError = FileOperationManager.INSTANCE.deleteFile (aUDO.getAsFile ()); if (aError.isFailure ()) LOGGER.error ("Failed to delete UDO " + aUDO.getPath () + ": " + aError.getErrorCode ()); return aError; }
/** * Write the current workbook to a file * * @param aFile * The file to write to. May not be <code>null</code>. * @return {@link ESuccess} */ @Nonnull public ESuccess writeTo (@Nonnull final File aFile) { return writeTo (FileHelper.getOutputStream (aFile)); }
public AbstractUserDataObject (@Nonnull @Nonempty final String sPath, final boolean bIsTemporary) { ValueEnforcer.notEmpty (sPath, "Path"); // Ensure only forward slashes m_sPath = FilenameHelper.getPathUsingUnixSeparator (FilenameHelper.ensurePathStartingWithSeparator (sPath)); m_bIsTemporary = bIsTemporary; }
public HTTPIncomingDumperDirectoryBased (@Nonnull final File aDumpDirectory) { ValueEnforcer.notNull (aDumpDirectory, "DumpDirectory"); ValueEnforcer.isTrue (FileHelper.existsDir (aDumpDirectory), () -> "DumpDirectory " + aDumpDirectory + " does not exist!"); m_aDumpDirectory = aDumpDirectory; }
@Nullable @ReturnsMutableCopy public ICommonsList <MimeTypeInfo> getAllInfosOfFilename (@Nullable final File aFile) { if (aFile == null) return null; final String sExtension = FilenameHelper.getExtension (aFile); return getAllInfosOfExtension (sExtension); }
/** * Constructor using the passed file as a working directory as the base URL * for the XQuery resource resolver. * * @param aBasePath * Base path for XQuery resource resolving. May not be * <code>null</code>. * @throws MalformedURLException * In case the conversion to URL failed */ public XQueryAsXPathFunctionConverter (@Nonnull final File aBasePath) throws MalformedURLException { this (FileHelper.getAsURLString (aBasePath)); }
@Nonnull private static String _getBundleIDFromFilename (@Nonnull final String sFilename) { // Cut leading path ("/") and file extension return FilenameHelper.getBaseName (sFilename); }
@Nonnull public static File getDirectoryFile (@Nonnull final String sDirectory) { final File aDir = new File (sDirectory); s_aFOM.createDirRecursiveIfNotExisting (aDir); return aDir; }
@Override protected String getModifiedURI (@Nonnull final String sURI) { if (LinkHelper.hasKnownProtocol (sURI)) { // If e.g. an external resource is includes. // Example: https://fonts.googleapis.com/css return sURI; } return FilenameHelper.getCleanConcatenatedUrlPath (sBasePath, sURI); } });
/** * Removes the file contents from the temporary storage. * * @throws Throwable * as declared by super.finalize() */ @Override protected void finalize () throws Throwable { FileOperations.deleteFileIfExisting (m_aDFOS.getFile ()); super.finalize (); }
@Nullable public static String getFilenameFromMessageID (@Nonnull final String sMessageID) { // Remove angle brackets manually String s = StringHelper.removeAll (sMessageID, '<'); s = StringHelper.removeAll (s, '>'); return FilenameHelper.getAsSecureValidASCIIFilename (s); } }
AuditHasFilename (@Nullable final String sBaseDir) { ValueEnforcer.isTrue (StringHelper.hasNoText (sBaseDir) || FilenameHelper.endsWithPathSeparatorChar (sBaseDir), () -> "BaseDir '" + sBaseDir + "' must end with path separator!"); m_sBaseDir = sBaseDir; }
public void deleteAllTemporaryFiles () { final ICommonsList <File> aTempFiles = m_aRWLock.writeLocked ( () -> { final ICommonsList <File> ret = m_aTempFiles.getClone (); m_aTempFiles.clear (); return ret; }); for (final File aTempFile : aTempFiles) { final FileIOError aIOError = FileOperations.deleteFileIfExisting (aTempFile); if (aIOError.isFailure ()) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete temporary file " + aTempFile + " with error " + aIOError.toString ()); _addTempFile (aTempFile); } } } }
@Nullable public String getNameSecure () { final String sSecureName = FilenameHelper.getAsSecureValidFilename (m_sFilename); if (!EqualsHelper.equals (sSecureName, m_sFilename)) if (LOGGER.isInfoEnabled ()) LOGGER.info ("FileItem filename was changed from '" + m_sFilename + "' to '" + sSecureName + "'"); return sSecureName; }
throw new CommandFailureException(e); ourLog.info("Fully read - Size is {}", FileHelper.getFileSizeDisplay(contents.length()));
/** * Constructor using the passed file as a working directory as the base URL * for the XQuery resource resolver. * * @param aBasePath * Base path for XQuery resource resolving. May not be * <code>null</code>. * @throws MalformedURLException * In case the conversion to URL failed */ public XQueryAsXPathFunctionConverter (@Nonnull final File aBasePath) throws MalformedURLException { this (FileHelper.getAsURLString (aBasePath)); }