我按照这个说明在android studio中添加了一个库.最后一步是添加一行manifestmerger.enabled=true在project.properties.我有一些.properties文件,如local.properties,gradle.properties,cache.properties但我无法找到project.properties文件.
我正在使用 Java 和 Jersey 开发 REST Web 服务器。这是我的第一个 Web 应用程序,我想确保我很好地构建了该应用程序。我创建了第一个运行良好的函数:
@Path("/startAuto")
public class Rest {
@GET
public String startAuto() {
try {
ProcessBuilder pb = new ProcessBuilder("/startAuto.sh");
Process p = pb.start();
p.waitFor();
return ("Auto Started");
} catch (Exception e) {
e.printStackTrace();
return ("error");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想添加一个新功能,例如stopAuto.
哪个更干净:在此类中添加函数或创建一个新类?
我有两种类型的字符串
command1|Destination-IP|DestinationPort
Command2|Destination-IP|DestinationPort|SourceIP|SourcePort|message
Run Code Online (Sandbox Code Playgroud)
我试图拆分String以获取我开始编码的变量,但不确定这是最好的方法
public String dstIp="";
public String dstPort="";
public String srcIp="";
public String scrPort="";
public String message="";
public String command="";
int first = sentence.indexOf ("|");
if (first > 0)
{
int second = sentence.indexOf("|", first + 1);
int third = sentence.indexOf("|", second + 1);
command = sentence.substring(0,first);
dstIp= sentence.substring(first+1,second);
dstPort= sentence.substring(second+1,third);
Run Code Online (Sandbox Code Playgroud)
我要继续这样吗?或者也许使用正则表达式?如果String是
command1|Destination-IP|DestinationPort
Run Code Online (Sandbox Code Playgroud)
我得到一个错误,因为没有第三个 |