底下这段C#代码转换成JAVA语言是怎样的?求大神帮助

下面这段C#代码转换成JAVA语言是怎样的?求大神帮助
string clientCommand = "";
                try
                {
                    clientCommand = System.Text.Encoding.UTF8.GetString(buffer);//转换接收的数据,数据来源于客户端发送的消息
                    if (clientCommand.Contains("%7C"))//从Android客户端传递部分数据
                        clientCommand = clientCommand.Replace("%7C", "|");//替换UTF中字符%7C为|
                }
------解决方案--------------------
buffer 是byte[]类型的吧,是不是可以改成这样?
我不了解C#,楼主试试吧,如果错了请忽略底下这段C#代码转换成JAVA语言是怎样的?求大神帮助

String clientCommand = "";
try {
clientCommand = new String(buffer,"utf-8");
if(clientCommand.contains("%7C")){
clientCommand.replace("%7C", "
------解决方案--------------------
");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}