Class: TextUtility
Author: Shahrzad Jahangirian
Language: Java (using Java 6) Download Java 6 and
Download Java Runtime 6(JRE)
Date Added: Dec 8, 2013
Description: TextUtility class includes Java String Utilities with two methods,
the first method is
isNumber(String input) String utility that takes a String and return a boolean value of true
if input is a number or return false if the entry is not a number.
The second method of this Java utility class is breakText(String text, String symbol, boolean keep), this method gets
some lines of text and split them by the symbol, and if keep parameter is true the symbol
also return with split words and it will be removed if keep is false.
How to Run: I tested all codes on Windows 7 Command Prompt with
Java(TM) SE Runtime Environment 6 on my computer. ( you may download it by visiting
this link )
You need to create all files and save it in a folder in your computer such as C:\javacodes
and compile and run at command prompt as follows. I assumed you saved all files at C:\javacodes
C:\javacodes> javac TextUtility.java -d c:\javacodes "this statement compiles the class and creates TextUtilityPKG package"
C:\javacodes> javac BreakTextMain.java "compiles the Main class to test BreakText method of TextUtility class"
C:\javacodes> Java BreakTextMain "and this statement runs the BreakTextMain.java"
C:\javacodes> javac IsNumberMain.java "compiles the Main class to test isNumber method from TextUtility class."
C:\javacodes> Java IsNumberMain "and this statement runs the IsNumberMain.java"
TextUtility Java class code that has java string split example method that uses Java StringTokenizer
This is the BreakTextMain class to runs breakText method of TextUtility class from Java command line input
This is the IsNumberMain class to runs isNumber method of TextUtility class from Java command line input