I am trying to develop an application which captures and then modifies a file on a Windows PC. I have been successful in transferring the text file over to the Smart Phone but when I try to open it I get this: Error occurred on line: 108 (Main) java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 Line 108 is this: "Log(DataRead.Get(0))"
Below is the code involved.
Sub BtnTest_click
Dim User As String
Dim Pass As String
Dim Filename As String
Dim FileLocation As String
Dim LocalDirectory As String
Dim DataTemp As String
Dim DataRead As List
Dim DataReadLast As List
Dim StringItem As StringUtils
Dim OneLine As String
Dim Lstlabel As Label
Dim I,J As Int
Filename = "Removals.txt"
LocalDirectory = "NetworkJournal"
User = "Optical_User"
Pass = "LORDSWILL"
SMB1.Initialize("SMB1")
DataRead.Initialize
SMB1.SetCredentials(User,Pass,"")
FileLocation = "smb://192.168.100.114/NetworkJournal/"
''File.MakeDir(File.DirDefaultExternal,LocalDirectory)
' SMB1.DownloadFile(FileLocation,Filename,File.DirRootExternal & "/" & LocalDirectory,Filename)
SMB1.DownloadFile(FileLocation,Filename,File.DirRootExternal,Filename)
If File.Exists(File.DirRootExternal,Filename) Then
' File.Exists(File.DirRootExternal & "/" & LocalDirectory,Filename) Then
Log("File " & Filename & " exists.")
Else
Log("File " & Filename & " does not exist.")
End If
''DataRead = File.ReadList(File.DirRootExternal & "/" & LocalDirectory,Filename)
DataRead = File.ReadList(File.DirRootExternal,Filename)
' DataRead = File.ReadList(File.DirDefaultExternal,Filename)
' DataRead = File.ReadList(File.DirDefaultExternal,"Journalfile.txt")
Log("The name of the file is:" & Filename)
Log("File.DirRootExternal =" & File.DirRootExternal)
Log(DataRead.Size)
Log(DataRead.Get(0))
It died here but there is more code after this.
Here is what Logger shows:
Logger connected to: samsung SM-S327VL
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
File Removals.txt exists.
The name of the file is:Removals.txt
File.DirRootExternal =/storage/emulated/0
0
Error occurred on line: 108 (Main)
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
Can you tell me why the size of the file is marked as zero even though the file does exist?
Below is the code involved.
Sub BtnTest_click
Dim User As String
Dim Pass As String
Dim Filename As String
Dim FileLocation As String
Dim LocalDirectory As String
Dim DataTemp As String
Dim DataRead As List
Dim DataReadLast As List
Dim StringItem As StringUtils
Dim OneLine As String
Dim Lstlabel As Label
Dim I,J As Int
Filename = "Removals.txt"
LocalDirectory = "NetworkJournal"
User = "Optical_User"
Pass = "LORDSWILL"
SMB1.Initialize("SMB1")
DataRead.Initialize
SMB1.SetCredentials(User,Pass,"")
FileLocation = "smb://192.168.100.114/NetworkJournal/"
''File.MakeDir(File.DirDefaultExternal,LocalDirectory)
' SMB1.DownloadFile(FileLocation,Filename,File.DirRootExternal & "/" & LocalDirectory,Filename)
SMB1.DownloadFile(FileLocation,Filename,File.DirRootExternal,Filename)
If File.Exists(File.DirRootExternal,Filename) Then
' File.Exists(File.DirRootExternal & "/" & LocalDirectory,Filename) Then
Log("File " & Filename & " exists.")
Else
Log("File " & Filename & " does not exist.")
End If
''DataRead = File.ReadList(File.DirRootExternal & "/" & LocalDirectory,Filename)
DataRead = File.ReadList(File.DirRootExternal,Filename)
' DataRead = File.ReadList(File.DirDefaultExternal,Filename)
' DataRead = File.ReadList(File.DirDefaultExternal,"Journalfile.txt")
Log("The name of the file is:" & Filename)
Log("File.DirRootExternal =" & File.DirRootExternal)
Log(DataRead.Size)
Log(DataRead.Get(0))
It died here but there is more code after this.
Here is what Logger shows:
Logger connected to: samsung SM-S327VL
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
File Removals.txt exists.
The name of the file is:Removals.txt
File.DirRootExternal =/storage/emulated/0
0
Error occurred on line: 108 (Main)
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
Can you tell me why the size of the file is marked as zero even though the file does exist?