What is the Android/Java corresponding method to the C# Stream object method Write()? -
a snippet of code want translate here:
class mk { stream connection; tcpclient con; public mk(string ip) { con = new tcpclient(); con.connect(ip, 8728); connection = (stream)con.getstream(); } public void close() { connection.close(); con.close(); } public bool login(string username, string password) { send("/login", true); string hash = read()[0].split(new string[] { "ret=" }, stringsplitoptions.none)[1]; send("/login"); send("=name=" + username); send("=response=00" + encodepassword(password, hash), true); if (read()[0] == "!done") { return true; } else { return false; } } public void send(string co) { byte[] bajty = encoding.ascii.getbytes(co.tochararray()); byte[] velikost = encodelength(bajty.length); connection.write(velikost, 0, velikost.length); connection.write(bajty, 0, bajty.length); } public void send(string co, bool endsentence) { byte[] bajty = encoding.ascii.getbytes(co.tochararray()); byte[] velikost = encodelength(bajty.length); connection.write(velikost, 0, velikost.length); connection.write(bajty, 0, bajty.length); connection.writebyte(0); }
the equivalent of stream.write
outputstream.write
... it's not clear whether enough you. (it's not clear why current code using encoding.ascii.getbytes(co.tochararray())
instead of encoding.ascii.getbytes(co)
Comments
Post a Comment