Skip to content

Commit 865f4eb

Browse files
committed
rename function names - for better understanding
1 parent 3892bfc commit 865f4eb

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/src/main/java/com/asutosh/documentreader/DocumentReaderUtil.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DocumentReaderUtil {
3737
* @param uri - uri of the file on device
3838
* @param context - context object
3939
*/
40-
fun readPdfFileContent(uri: Uri?, context: Context?): String {
40+
fun readPdfFromUri(uri: Uri?, context: Context?): String {
4141
PDFBoxResourceLoader.init(context)
4242
val file = File(context?.let { FilePathHelper(it).getPath(uri!!) }!!)
4343

@@ -56,7 +56,7 @@ class DocumentReaderUtil {
5656
* @param file - the file on device
5757
* @param context - context object
5858
*/
59-
fun readPdfFileContent(file: File?, context: Context?): String {
59+
fun readPdfFromFile(file: File?, context: Context?): String {
6060
PDFBoxResourceLoader.init(context)
6161

6262
val parser = PDFParser(RandomAccessFile(file, "r"))
@@ -67,16 +67,14 @@ class DocumentReaderUtil {
6767
val pdfStripper = PDFTextStripper()
6868
var document: PDDocument? = null
6969
document = PDDocument(cosDoc)
70-
pdfStripper.startPage = 0
71-
pdfStripper.endPage = 1
7270
return pdfStripper.getText(document)
7371
}
7472

7573
/**
7674
* @param uri - uri of the file on device
7775
* @param context - context object
7876
*/
79-
fun readTxtFileContent(uri: Uri?, context: Context?): String {
77+
fun readTxtFromUri(uri: Uri?, context: Context?): String {
8078

8179
val inputStream = context?.contentResolver?.openInputStream(uri!!)
8280
val bufferedReader = BufferedReader(InputStreamReader(inputStream!!, "UTF-8"))
@@ -92,7 +90,7 @@ class DocumentReaderUtil {
9290
* @param uri - uri of the file on device
9391
* @param context - context object
9492
*/
95-
fun readWordDocFile(uri: Uri?, context: Context?): String {
93+
fun readWordDocFromUri(uri: Uri?, context: Context?): String {
9694

9795
val file = File(context?.let { FilePathHelper(it).getPath(uri!!) }!!)
9896
val fullDocumentString: StringBuilder = StringBuilder()
@@ -124,7 +122,7 @@ class DocumentReaderUtil {
124122
* @param file - the file on device
125123
* @param context - context object
126124
*/
127-
fun readWordDocFile(file: File?, context: Context?): String {
125+
fun readWordDocFromFile(file: File?, context: Context?): String {
128126

129127
val fullDocumentString: StringBuilder = StringBuilder()
130128
val fis = FileInputStream(file?.absolutePath!!)

0 commit comments

Comments
 (0)