• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert VB.net to java

 
kumar krishnan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am a new bie in java platform Could any body to help to me i want try to convert the VB.net to java as below code i was struggle to get the solution Can any body advice to solve.

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
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

It's not easy to convert the given code straight from VB.net to Java as this code uses calls that don't have a direct equivalent in Java. I would suggest to write out in detail what you want to do and then try to write the Java code to do it.
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no easy way to convert VB.net to Java. As Tony suggested working out the logic as if it is Java will be best approach.

The I/O section of the Java tutorial here will give you a start.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!