public class FileProcessor
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
status |
Constructor and Description |
---|
FileProcessor() |
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getEmbeddedSubstrings(java.lang.String file,
java.lang.String regexStart,
java.lang.String regexStop)
Attempts to open the file and process each line in the file
with the StringProcessor.getEmbeddedSubstring method.
|
java.lang.String |
getTextFileContents(java.lang.String file)
Read the contents of a text file line-by-line.
|
int |
returnStatus()
returns the status code of the last function called.
|
int |
writeStringToFile(java.lang.String filename,
java.lang.String text)
Opens the file for writing, write the text, and close the file.
|
public java.lang.String[] getEmbeddedSubstrings(java.lang.String file, java.lang.String regexStart, java.lang.String regexStop)
Example string: "abcdefghi"
regexStart="abc"
regexStop ="ghi"
returned substring="def"
It returns a String[] of all the matching substrings.
Limitations: this method only returns the first match in a line. Subsequent matches appearing in the same line are ignored.
file
- case-insensitive full absolute path to the file to process. The file is
assumed to be in the default System codepage format. However, if the file contains
valid UTF-8 marker bytes (239, 187, 191) then it will be opened as a UTF-8 file.regexStart
- regular expression that identifies the characters immediately before
the substring to be extracted.regexStop
- regular expression that identifies the characters immediately following
the substring to be extracted.StringProcessor.getEmbeddedSubstring(String, String, String)
,
FileUtilities.isFileUTF8(String)
public int returnStatus()
The following codes are implemented:
0 - Success
17 - File Open Error
18 - File Read Error
6 - Unknown Error
public java.lang.String getTextFileContents(java.lang.String file)
file
- case-insensitive full absolute path to the file to process. The file is
assumed to be in the default System codepage format. However, if the file contains
valid UTF-8 marker bytes (239, 187, 191) then it will be opened as a UTF-8 file.FileUtilities.isFileUTF8(String)
public int writeStringToFile(java.lang.String filename, java.lang.String text)
filename
- case-insensitive full absolute path to the file to process. The file is
assumed to be in the default System codepage format.text
- String to write to the output file. The text will be written in the default
System codepage format.Copyright © SAS Institute. All Rights Reserved.