Klasse SimpleJavaUtils

java.lang.Object
ch.framedev.simplejavautils.SimpleJavaUtils

public class SimpleJavaUtils extends Object
  • Felddetails

    • logger

      public static Logger logger
  • Konstruktordetails

    • SimpleJavaUtils

      public SimpleJavaUtils()
  • Methodendetails

    • objectToBase64

      public <T extends Serializable> String objectToBase64(T object)
      Create a String of a Base64 (encode)
      Parameter:
      object - the Object to encode to Base64
      Gibt zurück:
      returns the encoded Base64 Byte Array
    • objectFromBase64

      public <T> T objectFromBase64(String base)
      Decode a Base64 String
      Parameter:
      base - the encoded Base64
      Gibt zurück:
      returns the decoded Object
    • saveObjectToBase64File

      public <T extends Serializable> void saveObjectToBase64File(File file, T object)
      Save an object to a Base64 File
      Typparameter:
      T - need to extend Serializable
      Parameter:
      file - the selected File for Save
      object - the Object to Save
    • getObjectFromBase64File

      public <T> T getObjectFromBase64File(File file)
      Return an Object as (T) from a File
      Typparameter:
      T - the Object
      Parameter:
      file - the Selected File where the Base64 File is stored
      Gibt zurück:
      return an Object from a Base64 String File
    • debug

      public void debug(Object object)
      Debug an Object
      Parameter:
      object - the Object for debugging
    • error

      public void error(Object object)
      Print an Error with the Object (System.err.println())
      Parameter:
      object - the selected Object for printing an error
    • createLogger

      public Logger createLogger(String name)
      Parameter:
      name - the Name of the new Logger
      Gibt zurück:
      returns the new Created Logger
    • stringSplitter

      public String[] stringSplitter(String text, @NotNull @NotNull String regex)
      Parameter:
      text - the Text for Splitting
      regex - the char for splitting
      Gibt zurück:
      return an Array of split Strings
    • createEmptyLogger

      public Logger createEmptyLogger(String name, boolean timeFormat)
      This Method Creates a Logger from scratch
      Parameter:
      name - the Name of the new Logger
      timeFormat - if you would like an TimeStamp in logger
      Gibt zurück:
      return the new Logger
    • round

      public double round(double value, int places)
      Round a double value to the giving Places
      Parameter:
      value - The Value to Round
      places - the Places where the Comma will bee
      Gibt zurück:
      return the Rounded Value of the giving Value to the Places
    • download

      public void download(String fileUrl, String location, String fileNameWithExtensions, String newLocation)
      Download a File from an Url and copying it to a new Folder
      Parameter:
      fileUrl - the Download Url
      location - the Location where the Downloaded file will be added
      fileNameWithExtensions - the FileName with the extension
      newLocation - the new Location where the File will be
    • download

      public void download(String fileUrl, String location, String fileNameWithExtensions)
      Download a File from an Url
      Parameter:
      fileUrl - Download Url for File to Download
      location - the new Location of the Download
      fileNameWithExtensions - the FileName with the new extension
    • getTempDir

      public String getTempDir()
      Get The Temp Directory
      Gibt zurück:
      return the Temp Directory
    • getUserHome

      public String getUserHome()
      Get The User Home Directory
      Gibt zurück:
      return the User Home Directory
    • getUserDir

      public String getUserDir()
      Get the User's Directory
      Gibt zurück:
      return the User Directory
    • getUserAppData

      public String getUserAppData()
      Get the user Applications Store Folder
      Gibt zurück:
      return the Applications Store Folder
    • getOs

      public String getOs()
      Return the Operating System Name
      Gibt zurück:
      return the Os Name
    • getOsVersion

      public String getOsVersion()
      Return Os's Version
      Gibt zurück:
      return the Os Version
    • streamToFile

      protected File streamToFile(InputStream in)
      Parameter:
      in - InputStream
      Gibt zurück:
      the File from the InputStream
    • getFromResourceFile

      public File getFromResourceFile(String file)
    • getFromResourceFile

      public File getFromResourceFile(String file, Class<?> class_)
    • existsFile

      public boolean existsFile(String fileName)
      Check if a File is existing
      Parameter:
      fileName - the FileName to check if it is existing or not
      Gibt zurück:
      return a boolean if exists or not
    • existsFile

      public boolean existsFile(File file)
      Check if the selected File is existing
      Parameter:
      file - the Selected File
      Gibt zurück:
      return if exists or not
    • copyFileTo

      public void copyFileTo(File source, File target) throws IOException
      Copy a File to a new Location
      Parameter:
      source - the Selected File to Copy
      target - the Selected File where the File will be copied
      Löst aus:
      IOException - throw an IOException if an error occurred
    • moveFileTo

      public void moveFileTo(File source, File target) throws IOException
      Move a File to the new Location
      Parameter:
      source - the File to Move
      target - the File where the File will be moved
      Löst aus:
      IOException - throw an IOException if an error occurred
    • zipDirectory

      public File zipDirectory(File directory, File outPut) throws IOException
      Zipping a Complete Directory
      Parameter:
      directory - the Selected Directory for zipping
      Gibt zurück:
      return the Zipped Directory as .zip
      Löst aus:
      IOException - throw an IOException if an Error occurred
    • zipFiles

      public File zipFiles(File zipFile, File... files) throws IOException
      Create a Zip Archive where the Files contains
      Parameter:
      zipFile - the Zip file where all Files contains
      files - the Selected Files for Zipping
      Gibt zurück:
      return the Zipped File
      Löst aus:
      IOException - throw when unsuccessful
    • isOnline

      public static boolean isOnline(String server, int port, int timeout)
      Check if Server with Port is Online or can connect
      Parameter:
      server - Server Ip or HostName
      port - port as example for MySQL 3306
      timeout - how long is it trying to connect
      Gibt zurück:
      return if is Online or not
    • isOnline

      public boolean isOnline(String server, int port)
      Check if Server with Port is Online or can Connect Timeout default is 2500 Milliseconds
      Parameter:
      server - Server Ip or HostName
      port - port as example for MySQL 3306
      Gibt zurück:
      return if is Online or not
    • getLogger

      public Logger getLogger()
    • getFilePath

      public String getFilePath()
      Retrieves the file path of the application based on the operating system. If the operating system is Windows, the method returns the file path with a backslash as the separator. For other operating systems, the method returns the file path with a forward slash as the separator. If an error occurs while getting the file path, a runtime exception is thrown with the original exception as the cause.
      Gibt zurück:
      the file path of the application
    • getFilePath

      public String getFilePath(Class<?> clazz)
      Retrieves the file path of the application based on the operating system. If the operating system is Windows, the method returns the file path with a backslash as the separator. For other operating systems, the method returns the file path with a forward slash as the separator. If an error occurs while getting the file path, a runtime exception is thrown with the original exception as the cause.
      Gibt zurück:
      the file path of the application
    • encodeFileToBase64BinaryArray

      public byte[] encodeFileToBase64BinaryArray(File file)
    • decodeFileFromBase64Binary

      public File decodeFileFromBase64Binary(byte[] decodedFile, String extension, String fileName, String location)
    • decodeFileFromBase64BinaryTmp

      public File decodeFileFromBase64BinaryTmp(byte[] decodedFile, String extension)