我只是想知道在类实例中是否可以使用getter方法访问类变量,以及是否与直接访问有任何明显的性能差异.特别是在预期在jvm中生成许多对象的情况下.
我想在逗号(,)上用java分割字符串,但只要逗号(,)在某个括号之间,就不应该拆分.
例如,字符串:
"life, would, (last , if ), all"
Run Code Online (Sandbox Code Playgroud)
应该产量:
-life
-would
-(last , if )
-all
Run Code Online (Sandbox Code Playgroud)
我用的时候:
String text = "life, would, (last , if ), all"
text.split(",");
Run Code Online (Sandbox Code Playgroud)
我最终将整个文本划分为(最后,如果)我可以看到拆分需要一个正则表达式,但我似乎无法想到如何使它完成工作.
我有一个类,有一个阻止的方法,并希望验证它是阻塞的.方法如下所示.
public static void main(String[] args) {
// the main routine is only here so I can also run the app from the command line
applicationLauncherInstance.initialize();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
if (null != application) {
applicationLauncherInstance.terminate();
}
}
});
try {
_latch.await();
} catch (InterruptedException e) {
log.warn(" main : ", e);
}
System.exit(0);
}
Run Code Online (Sandbox Code Playgroud)
如何为这种方法编写单元测试.我在开始前被卡住了.
public class ApplicationLauncherTest extends TestCase {
public void testMain() throws Exception {
ApplicationLauncher launcher = new ApplicationLauncher();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个pg_xlog目录填满的服务器。我需要确定要删除的 WAL(Write Ahead Log)文件,并根据此链接我需要pg_controldata它在安装了 postgresql-contrib-9.4 的 ubuntu 中不可用。
我该如何继续?
在学习如何使用akka I/OI时,我试图在akka i/o上实现一个简单的协议,并在此处遵循文档.
但是在我的gradle文件中,我使用版本2.3.9,如下所示
dependencies {
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.7'
compile group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.3.9'
compile group: 'com.typesafe.akka', name: 'akka-contrib_2.11', version: '2.3.9'
compile group: 'org.scala-lang', name: 'scala-library', version: '2.11.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Run Code Online (Sandbox Code Playgroud)
导入一些特定于管道的东西
import akka.io.SymmetricPipelineStage;
import akka.io.PipelineContext;
import akka.io.SymmetricPipePair;
Run Code Online (Sandbox Code Playgroud)
生成无法解决符号错误.
因此我的问题.
java ×4
akka ×1
akka-io ×1
archiving ×1
class ×1
junit ×1
pipeline ×1
postgresql ×1
regex ×1
split ×1
string-split ×1
tcp ×1
ubuntu ×1
unit-testing ×1