Class FileUtils

java.lang.Object
jadx.core.utils.files.FileUtils

public class FileUtils extends Object
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • READ_BUFFER_SIZE

      public static final int READ_BUFFER_SIZE
      See Also:
    • MAX_FILENAME_LENGTH

      private static final int MAX_FILENAME_LENGTH
      See Also:
    • MAX_UNIQUE_ID_LENGTH

      private static final int MAX_UNIQUE_ID_LENGTH
      See Also:
    • JADX_TMP_INSTANCE_PREFIX

      public static final String JADX_TMP_INSTANCE_PREFIX
      See Also:
    • JADX_TMP_PREFIX

      public static final String JADX_TMP_PREFIX
      See Also:
    • tempRootDir

      private static Path tempRootDir
    • MKDIR_SYNC

      private static final Object MKDIR_SYNC
    • HEX_ARRAY

      private static final byte[] HEX_ARRAY
    • ZIP_FILE_MAGIC

      private static final byte[] ZIP_FILE_MAGIC
  • Constructor Details

    • FileUtils

      private FileUtils()
  • Method Details

    • updateTempRootDir

      public static Path updateTempRootDir(Path newTempRootDir)
    • createTempRootDir

      private static Path createTempRootDir()
    • listFiles

      public static List<Path> listFiles(Path dir)
    • listFiles

      public static List<Path> listFiles(Path dir, Predicate<? super Path> filter)
    • expandDirs

      public static List<Path> expandDirs(List<Path> paths)
    • expandDir

      private static void expandDir(Path dir, List<Path> files)
    • addFileToJar

      public static void addFileToJar(JarOutputStream jar, File source, String entryName) throws IOException
      Throws:
      IOException
    • makeDirsForFile

      public static void makeDirsForFile(Path path)
    • makeDirsForFile

      public static void makeDirsForFile(File file)
    • makeDirs

      public static void makeDirs(@Nullable @Nullable File dir)
    • makeDirs

      public static void makeDirs(@Nullable @Nullable Path dir)
    • deleteFileIfExists

      public static void deleteFileIfExists(Path filePath) throws IOException
      Throws:
      IOException
    • deleteDir

      public static boolean deleteDir(File dir)
    • deleteDir

      public static void deleteDir(Path dir)
    • deleteDirIfExists

      public static void deleteDirIfExists(Path dir)
    • deleteDir

      private static void deleteDir(Path dir, boolean keepRootDir)
    • clearTempRootDir

      public static void clearTempRootDir()
    • clearDir

      public static void clearDir(Path clearDir)
    • createTempDir

      @Deprecated public static Path createTempDir(String prefix)
      Deprecated.
      Deprecated. Migrate to IJadxFilesGetter from jadx args to get temp dir
    • createTempFile

      @Deprecated public static Path createTempFile(String suffix)
      Deprecated.
      Deprecated. Migrate to IJadxFilesGetter from jadx args to get temp dir
    • createTempFileNoDelete

      @Deprecated public static Path createTempFileNoDelete(String suffix)
      Deprecated.
      Deprecated. Prefer IJadxFilesGetter from jadx args to get temp dir
    • createTempFileNonPrefixed

      @Deprecated public static Path createTempFileNonPrefixed(String fileName)
      Deprecated.
      Deprecated. Migrate to IJadxFilesGetter from jadx args to get temp dir
    • copyStream

      public static void copyStream(InputStream input, OutputStream output) throws IOException
      Throws:
      IOException
    • streamToByteArray

      public static byte[] streamToByteArray(InputStream input) throws IOException
      Throws:
      IOException
    • streamToString

      public static String streamToString(InputStream input) throws IOException
      Throws:
      IOException
    • close

      public static void close(Closeable c)
    • writeFile

      public static void writeFile(Path file, String data) throws IOException
      Throws:
      IOException
    • writeFile

      public static void writeFile(Path file, byte[] data) throws IOException
      Throws:
      IOException
    • writeFile

      public static void writeFile(Path file, InputStream is) throws IOException
      Throws:
      IOException
    • readFile

      public static String readFile(Path textFile) throws IOException
      Throws:
      IOException
    • renameFile

      public static boolean renameFile(Path sourcePath, Path targetPath)
    • prepareFile

      @NotNull public static @NotNull File prepareFile(File file)
    • cutFileName

      public static File cutFileName(File file)
    • bytesToHex

      public static String bytesToHex(byte[] bytes)
    • byteToHex

      public static String byteToHex(int value)
      Zero padded hex string for first byte
    • intToHex

      public static String intToHex(int value)
      Zero padded hex string for int value
    • isZipFile

      public static boolean isZipFile(File file)
    • getPathBaseName

      public static String getPathBaseName(Path file)
    • hasExtension

      public static boolean hasExtension(Path path, String extension)
    • toFile

      public static File toFile(String path)
    • toPaths

      public static List<Path> toPaths(List<File> files)
    • toPaths

      public static List<Path> toPaths(File[] files)
    • toPathsWithTrim

      public static List<Path> toPathsWithTrim(File[] files)
    • toPathWithTrim

      public static Path toPathWithTrim(File file)
    • toPathWithTrim

      public static Path toPathWithTrim(String file)
    • fileNamesToPaths

      public static List<Path> fileNamesToPaths(List<String> fileNames)
    • toFiles

      public static List<File> toFiles(List<Path> paths)
    • md5Sum

      public static String md5Sum(String str)
    • md5Sum

      public static String md5Sum(byte[] data)
    • buildInputsHash

      public static String buildInputsHash(List<Path> inputPaths)
      Hash timestamps of input files