public class TextFileUtility extends Object
Constructor and Description |
---|
TextFileUtility() |
Modifier and Type | Method and Description |
---|---|
static void |
appendLine(File file,
String line)
Read Text File: Append new line to existing text file.
|
static void |
appendLine(String filePath,
String line)
Read Text File: Append new line to existing text file.
|
static boolean |
compareTextFiles(File fSrc,
File fCmp,
boolean ignoreCase)
Compare Text File: Compare two text files and also consider or ignore case.
|
static boolean |
compareTextFiles(String fSrcPath,
String fCmpPath,
boolean ignoreCase)
Compare Text File: Compare two text files and also consider or ignore case.
|
static void |
createTextFile(File file)
Create Text File: Function used to create new text file.
|
static void |
createTextFile(String filePath)
Create Text File: Function used to create new text file.
|
static List<String> |
readTextFile(File file)
Read Text File: Used to read text file.
|
static List<String> |
readTextFile(String filePath)
Read Text File: Used to read text file.
|
static void |
replaceRegrex(File fSrc,
String regrex,
String strReplace)
Replace String In text file: It will search text based on regular expression and replace all matching text from file.
|
static void |
replaceRegrex(String fSrcPath,
String regrex,
String strReplace)
Replace String In text file: It will search text based on regular expression and replace all matching text from file.
|
static boolean |
searchRegrex(File fSrc,
String regrex)
Search String using regular expression: Search text based on regular expression.
|
static boolean |
searchRegrex(String fSrcPath,
String regrex)
Search String using regular expression: Search text based on regular expression.
|
public static void createTextFile(String filePath) throws IOException
filePath
- is string and it contains location of text file.IOException
- if file already exist at specified location.public static void createTextFile(File file) throws IOException
file
- object passed as a parameter.IOException
- if file already exist at specified location.File
public static List<String> readTextFile(String filePath) throws IOException
filePath
- is string object and it contains location of text file. List
IOException
- if file does not exists.public static List<String> readTextFile(File file) throws IOException
file
- object used as parameter. List
IOException
- if file does not exists.public static void appendLine(String filePath, String line) throws IOException
filePath
- is string object and it contains location of text file.line
- is string to append existing text file.IOException
- if file does not exists.public static void appendLine(File file, String line) throws IOException
file
- object used to pass.line
- is string to append existing text file.IOException
- if file does not exists.public static boolean compareTextFiles(File fSrc, File fCmp, boolean ignoreCase) throws IOException
fSrc
- is first text file.fCmp
- is second text file.ignoreCase
- is boolean value to/not to ignore case. boolean
as true if both files are same otherwise it will return false.IOException
- if file size not same or file dosen't exist.public static boolean compareTextFiles(String fSrcPath, String fCmpPath, boolean ignoreCase) throws IOException
fSrcPath
- is first text file path in string.fCmpPath
- is second text file path in string.ignoreCase
- is boolean value to/not to ignore case. boolean
as true if both files are same otherwise it will return false.IOException
- if file size not same or file dosen't exist.public static boolean searchRegrex(String fSrcPath, String regrex) throws IOException
fSrcPath
- is text file path in string.regrex
- is regular expression string. boolean
This method will return true if text within file satisfies regular expression.IOException
- if file not found.public static boolean searchRegrex(File fSrc, String regrex) throws IOException
fSrc
- is text file object.regrex
- is regular expression string. boolean
This method will return true if text within file satisfies regular expression.IOException
- if file not found.public static void replaceRegrex(File fSrc, String regrex, String strReplace) throws IOException
fSrc
- is text file object.regrex
- is regular expression string.strReplace
- is new string to be replaced with old oneIOException
- if file not found.public static void replaceRegrex(String fSrcPath, String regrex, String strReplace) throws IOException
fSrcPath
- is text file path in string.regrex
- is regular expression string.strReplace
- is replacement string.IOException
- if file not found.