Class Utils

java.lang.Object
ch.software_atelier.simpleflex.Utils

public class Utils extends Object
This Class holds some static Utility-methods
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • getMimeFromFilePath

      public static String getMimeFromFilePath(String path)
    • registerMime

      public static void registerMime(String suffix, String mime)
    • getResource

      public static String getResource(String name)
    • main

      public static void main(String[] args)
    • readBytesUntilNewLine

      public static byte[] readBytesUntilNewLine(InputStream is) throws IOException
      Reads all bytes of a BuferedInputStream untill a NewLine-Char and returns the readed data as a String. This Method blocks, if no data is aviable and only stops on a newline- or EOF-char!
      Parameters:
      is - The InputStream
      Returns:
      The readed Data or null on EOF.
      Throws:
      IOException
    • readUntilNewLine

      public static String readUntilNewLine(BufferedInputStream is, boolean trim) throws IOException
      Reads all bytes of a BuferedInputStream untill a NewLine-Char and returns the readed data as a String. This Method blocks, if no data is aviable and only stops on a newline- or EOF-char!
      Parameters:
      is - The InputStream
      trim - trims the String
      Returns:
      The readed Data or null on EOF.
      Throws:
      IOException
    • splitHeader

      public static String[] splitHeader(String header)
    • getFileExtension

      public static String getFileExtension(String fileName)
    • getHTTPDateHeaderValue

      public static String getHTTPDateHeaderValue(Date d)
    • readFile

      public static byte[] readFile(File f)
    • tokenize

      public static List<String> tokenize(String src, String separator)
    • parseLong

      public static long parseLong(String s)
    • file2JSON

      public static org.json.JSONObject file2JSON(File f) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • tokenizeByIgnoringEnclosure

      public static List<String> tokenizeByIgnoringEnclosure(String src, char separator, char enclosure)
    • removeNonEscaped

      public static String removeNonEscaped(String src, char remove, char escape)