Convert VB.NET code to Java
Private Sub UploadFile(ByVal filename As String)Try
Dim strFile As String = System.IO.Path.GetFileName(filename)
Dim fInfo As New FileInfo(filename)
Dim numBytes As Long = fInfo.Length
Dim dLen As Double = Convert.ToDouble(fInfo.Length / 1000000)
If dLen < 4 Then
Dim fStream As New FileStream(filename, FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fStream)
Dim data As Byte() = br.ReadBytes(CInt(numBytes))
br.Close()
Dim sTmp As String = Me.objService.UploadFile(data, strFile)
fStream.Close()
fStream.Dispose()
MessageBox.Show("File Upload Status: " & sTmp, "File Upload")
Else
MessageBox.Show("The file selected exceeds the size limit for uploads.", "File Size")
End If
Catch ex As Exception
_objLog.WriteToErrorLog("Synchronization", "UploadFile", ex.Message, "")
If MessageBox.Show(ex.Message, "Msg", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.OK Then
Exit Sub
End If
End Try
End Sub
Thanks and regards
kumar
