VB.net Java Code Gen放置不需要的空间

时间:2015-11-08 15:56:03

标签: java vb.net string

您好我试着让一个VB.net应用程序让我为插件创建一些java代码我正在制作这是vb.net应用程序的代码

Public Class Form1


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim s As String = ""
        Dim i As Integer = 0
        Dim X As Integer = Int(TextBox2.Text)
        Dim Z As Integer = Int(TextBox3.Text)
        Dim YDif As Integer = Int(TextBox4.Text)
        Dim YStart As Integer = Int(TextBox5.Text)
        Dim World As String = TextBox6.Text
        Dim Building As String = TextBox1.Text
        Dim Y As Integer = 0
        'Diff * Floor + Start
        '6 * 0 + start
        Do Until i = NumericUpDown1.Value
            Y = (YDif * i) + YStart
            s = s + "LiftHandeler.Buildings.put(loc(""" + World + """," + Str(X) + "," + Str(Y) + "," + Str(Z) + "), """ + Building + """);" + vbNewLine
            i = i + 1
        Loop
        i = 0
        Do Until i = NumericUpDown1.Value
            Y = (YDif * i) + YStart
            s = s + "LiftHandeler.Floors.put(""" + Building + Str(i + 1) + """,loc(""" + World + """," + Str(X) + "," + Str(Y) + "," + Str(Z) + "));" + vbNewLine
            i = i + 1
        Loop

        s = s + "LiftHandeler.FloorsAmt.put(""" + Building + """, " + Str(NumericUpDown1.Value) + ");"

        My.Computer.Clipboard.SetText(s)
    End Sub
End Class

输出应该

LiftHandeler.Buildings.put(loc("world", 43, 22, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 26, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 30, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 34, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 38, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 42, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 46, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 50, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 54, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 58, 971), "Andrew");
LiftHandeler.Floors.put("Andrew1",loc("world", 43, 22, 971));
LiftHandeler.Floors.put("Andrew2",loc("world", 43, 26, 971));
LiftHandeler.Floors.put("Andrew3",loc("world", 43, 30, 971));
LiftHandeler.Floors.put("Andrew4",loc("world", 43, 34, 971));
LiftHandeler.Floors.put("Andrew5",loc("world", 43, 38, 971));
LiftHandeler.Floors.put("Andrew6",loc("world", 43, 42, 971));
LiftHandeler.Floors.put("Andrew7",loc("world", 43, 46, 971));
LiftHandeler.Floors.put("Andrew8",loc("world", 43, 50, 971));
LiftHandeler.Floors.put("Andrew9",loc("world", 43, 54, 971));
LiftHandeler.Floors.put("Andrew10",loc("world", 43, 58, 971));
LiftHandeler.FloorsAmt.put("Andrew",  10);

但它正在制作的代码输出是

LiftHandeler.Buildings.put(loc("world", 43, 22, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 26, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 30, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 34, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 38, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 42, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 46, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 50, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 54, 971), "Andrew");
LiftHandeler.Buildings.put(loc("world", 43, 58, 971), "Andrew");
LiftHandeler.Floors.put("Andrew 1",loc("world", 43, 22, 971));
LiftHandeler.Floors.put("Andrew 2",loc("world", 43, 26, 971));
LiftHandeler.Floors.put("Andrew 3",loc("world", 43, 30, 971));
LiftHandeler.Floors.put("Andrew 4",loc("world", 43, 34, 971));
LiftHandeler.Floors.put("Andrew 5",loc("world", 43, 38, 971));
LiftHandeler.Floors.put("Andrew 6",loc("world", 43, 42, 971));
LiftHandeler.Floors.put("Andrew 7",loc("world", 43, 46, 971));
LiftHandeler.Floors.put("Andrew 8",loc("world", 43, 50, 971));
LiftHandeler.Floors.put("Andrew 9",loc("world", 43, 54, 971));
LiftHandeler.Floors.put("Andrew 10",loc("world", 43, 58, 971));
LiftHandeler.FloorsAmt.put("Andrew",  10);

注意所有Floors.put标签上的建筑物名称(安德鲁)和楼层编号后的不需要的空间

1 个答案:

答案 0 :(得分:0)

通过替换

解决了问题
public final boolean readDataFromServer (String fileName)
{
    try
    {
        String url = "http://example.com/FolderName/".concat(fileName);
        URL webServer = new URL (url);
        Scanner reader = new Scanner(webServer.openStream());

        // reading data in variables by using nextLine() method

        reader.close();
        return true;
     }

     catch (MalformedURLException e)
    {
        return false;
    }
    catch (IOException e)
    {
        JOptionPane.showMessageDialog(null,"The file was not found on the server");
        return false;
    }
    catch (Exception e)     // this is the block where I'm getting an exception
    {
        System.out.println("Exception here");
        return false;

    }
}

使用

 s = s + "LiftHandeler.Floors.put(""" + Building + Str(i + 1) + """,loc(""" + World + """," + Str(X) + "," + Str(Y) + "," + Str(Z) + "));" + vbNewLine