Class Collection


A collection of classes and methods i think is useful.
See the class description below for more information on what SteelsquidClassCollection can do.




Content



Dependencies (All needed jar is under the lib directory)



Download

  • Here¬†you can download the project.


Usage

For example see package: org.steelsquid.classcollection.example and the class description below.



Short description of classes

  • org.steelsquid.classcollection.example
    Some of the examples do not work untill you edit them for your system.
    Here is a short description of the examples:
    - Sending a mail.
    - Testing some functions in the prophandler (Load properties from xml file easy).
    - Crypt/decrypt a stream with DES.
    - Print text to printer.
    - Read and write to console (formating the output and input).
    - Creating and extracting a zip-file.
    - Set classpath and library path in runtime. (The same as the -classpath and -Djava.library.path).
    - Settings temp properties. (Usefull if you want to save some values while restarting a application).
    - Sending, receiving and listing file on ftp server.
    - List files in a directory (recursively and a lot of filtering).
    - Test to start the steelsquidServer from inside a java program (SteelsquidServer se below).
    - Read response from a web page.
    - Get the external ip you have on the internet.
    - A test application for SteelsquidServer.

    Under the etc directory you can find the properties xml file you
    need to run the example (exampleProp.xml).
    How to run example:
    java -classpath ../lib/SteelsquidClassCollection.jar org.steelsquid.classcollection.example.Exec ../etc/exampleProp.xml
    Or:
    bin/execExample.sh
  • org.steelsquid.classcollection.common.Utils
    Contains som usefull methods.
    Se doc/javadoc/index.html for more inforamtion.
    - Check if a string is empty.
    - Cut up string into certain length. stringCutUp("abcdefgh",3 ) => abc def gh
    - Replace invalide xml chars
    - Get String between two other Strings. getStringBetweanStrings("aabbbcc", "aa", "cc") ==> bbb
    - Replace String between two other Strings. replaceStringBetweanStrings("aabbbcc", "aa", "cc", "ddd") ==> aadddcc
    - If execute getVariables("Hellow ", alist) firsname and lastname will be added to alist.
    - If execute setVariables("Hellow , "name", "steelsquid") will replace with steelsquid.
    - Generade a nice locking log string: [id] yyyy-MM-dd hh:mm:ss [Level] [text]
    - Break a string into tokens, stringTokenizer("hej|hopp||1|") ==> 'hej', 'hopp', '', '1', '' (also returns empty tokens)
    - Get random integer and string.
    - Copy from one stream to a nother.
    - Replace all occurences of text with another in a StringBuilder.
    - Get firstIndexOf and lastIndexOf char in a StringBulder
  • org.steelsquid.classcollection.common.UtilsConsole
    Contains som usefull methods for the console.
    Read, write, delete, backspace, clearScreen.
    Also use nice locking string from org.steelsquid.classcollection.common.Utils
    Se doc/javadoc/index.html for more inforamtion.
  • org.steelsquid.classcollection.file.UtilsFile
    Read, write, create, move copy, delete and other stuff on files.
    Se doc/javadoc/index.html for more inforamtion.
    - Change attribute on file
    - Walk a directory tree and return a List of files/directorys, can set a lot of filterng options (Se org.steelsquid.classcollection.example)
    - Delete a file/directory recursively.
    - Copy file or a dir. Copy recursively if a directory.
    - Move file or a dir.
    - Reading text content of a file.
    - Writing a text to a file.
    - Writing a stream to a file.
    - Read text from file in classpath.
    - Check if a file/dir is a link i unix/linux and windows (Do not know if this always work).
    - Check if a file/directory is sub directory of other directory and some other security checks to.
  • org.steelsquid.classcollection.common.UtilsTime
    Usefull things to handle date and time.
    Se doc/javadoc/index.html for more inforamtion.
    - Check if date is valide.
    - Get current date and time yyyy-MM-dd and HH:mm:ss
    - Parse and format date thread safe (yyyy-MM-dd and HH:mm:ss).
  • org.steelsquid.classcollection.file.zip
    - Creates a zip and add a directory content to it
    - Extract zip file to a directory
  • org.steelsquid.classcollection.loader
    - Load jar and set library path in runtime. (The same as the -classpat and -Djava.library.path)
  • org.steelsquid.classcollection.net.Socket.SocketClient
    A very simple class to send/receive text to/from a socket server.
  • org.steelsquid.classcollection.net.ftp
    - Sending, receiving and listing file on ftp server
  • org.steelsquid.classcollection.net.http.HttpClient
    - Read a html request from a server.
  • org.steelsquid.classcollection.net.UtilsNet
    - Check if port is free to use.
    - Get ip-number you have on the net.
  • org.steelsquid.classcollection.net.
    - Send a mail
  • org.steelsquid.classcollection.printer
    - Write text to a printer
  • org.steelsquid.classcollection.properties
    - Loading properties to application easy.
  • org.steelsquid.classcollection.security.crypto
    - Use DES to encrypt and decrypt a stream
    - Can use password or key-file
  • org.steelsquid.classcollection.server
    A easy to use package to use if you want to create small applications fast.
    - Configure the server by xml.
    - One server can contains multipple applications.
    - Send command by telnet to all applications.
    - You override this methods to do the work: onStart, running, onStop, onStopped, onException, onCommand

    Expecting xml properties file as input parameter (Se etc/exampleServerSettings.xml)

    You can test SteelsquidServer like this:
    java -classpath ../lib/steelsquidClassCollection.jar org.steelsquid.classcollection.server.Server ../etc/exampleServerSettings.xml

    You can also send command to a server on localhost like this (A command will be sent to all applications on the server onCommand(...)):
    java -classpath ../lib/steelsquidClassCollection.jar org.steelsquid.classcollection.server.Server ../etc/exampleServerSettings.xml This is a command
    A command is a string ending with \n (new line)
    You can also use telnet to send a command. Print your command followed by Enter.
    If multiple applications return answer they will be merged.
    The answer will always end with \n (new line)
    org.steelsquid.classcollection.net.http.JsoupConnector
    This class uses jsoup to parse html.
    Hidden fields, cookies and permanent parameters.
    Cookies will be read from the server response and moved to the next server request.
    If the server response has hidden fields they will be moved to the next server request.
    You can also set permanent paramaters that will be sent on every server request.


ToDo

  • Stop, start and restart application in SteelsquidServer


Licensing

  • SteelsquidClassCollection GNU Lesser General Public License
  • Jsoup License