2016-11-10 53 views
0

所以这里的问题:Java8 CompletionStage内容

如何真正得到这样的内容:

RxClient<RxCompletionStageInvoker> newRxClient = RxCompletionStage.newClient(); 
     CompletionStage<Response> stage = newRxClient 
        .target("somelink") 
        .request() 
        .rx()     
        .get() 
        .toCompletableFuture();   

相反的:

[email protected][Completed normally] 

编辑:发现的情况下,任何人的解决方案否则在这个问题上绊倒:

stage.toCompletableFuture().get() 
+0

你想作为一个输出什么?你能举个例子吗? – n247s

+0

该链接给出返回JSON,我想要得到该JSON作为输出。 – Rauno

回答

0

我guese你叫:

System.out.println(stage); 

其中要求stage.toString()其打印(CompatibleFuture)的对象,而不是它的内容。要获取Future对象的内容,只需使用stage.get()。所以下面应该给你Response对象的表示(如果由Response#toString()返回JSON字符串)

System.out.println(stage.get()); 

我希望这是你要找的人

+0

你的几乎是我在找的东西:stage.get()表示get是未定义的stage,但stage.toCompletableFuture()。get()的作品。无论如何感谢您的输入! – Rauno