小编Bwi*_*ire的帖子

是getter方法调用访问变量比在类中直接变量访问更好

我只是想知道在类实例中是否可以使用getter方法访问类变量,以及是否与直接访问有任何明显的性能差异.特别是在预期在jvm中生成许多对象的情况下.

java class

6
推荐指数
2
解决办法
1万
查看次数

Java在逗号(,)上拆分字符串,但在括号()之间除外

我想在逗号(,)上用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)

我最终将整个文本划分为(最后,如果)我可以看到拆分需要一个正则表达式,但我似乎无法想到如何使它完成工作.

java regex split string-split

5
推荐指数
1
解决办法
2326
查看次数

如何使用junit测试阻塞方法

我有一个类,有一个阻止的方法,并希望验证它是阻塞的.方法如下所示.

 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)

java junit unit-testing

3
推荐指数
1
解决办法
2466
查看次数

ubuntu 14.10 和 postgres 9.4 如何运行 pg_controldata

我有一个pg_xlog目录填满的服务器。我需要确定要删除的 WAL(Write Ahead Log)文件,并根据此链接我需要pg_controldata它在安装了 postgresql-contrib-9.4 的 ubuntu 中不可用。

我该如何继续?

postgresql ubuntu archiving

2
推荐指数
1
解决办法
1727
查看次数

是否从akka i/o中删除了管道?

在学习如何使用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)

生成无法解决符号错误.

因此我的问题.

  1. 如果删除了这些或者我需要添加到gradle文件中有一些依赖性.
  2. 如果删除它们,将如何处理编码/解码阶段?

java pipeline tcp akka akka-io

2
推荐指数
1
解决办法
477
查看次数