Tag: java

如何创build一个节点js函数,始终等待从java system.out.println新行?

我想寻求想法,我怎么可以创build一个函数,总是等待新线由于从我的Java应用程序通过标准输出延迟? 我想以一种方式显示到我的terminal控制台,数据是逐步呈现的,而不是一个整块。 这是我的Java代码: public class HelloWorld { public static void main(String[] args) { // Prints "Hello, World" to the terminal window. // System.out.println("Hello, Worldzzz"); for (int i=1; i<11; i++) { try { Thread.sleep(500); } catch (Exception e) { } System.out.println("Count is: " + i); } } } 这是我的节点js代码到目前为止: var http = require('http'), util = require('util'), […]

如何读取Node JS中的servlet响应输出stream?

用例是从服务器获取文件内容,并使用节点JS将其发送到浏览器。 细节: 在Java中读取一个文件(PDF,图像文件)(终点是使用spring框架公开的) @RequestMapping(value = "/getFileContent", method = RequestMethod.GET) public void getFileContent(HttpServletResponse response) throws IOException { try { File file = new File("src/main/resources/SampleDoc.pdf"); InputStream targetStream = new FileInputStream(file); response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "inline; filename="+"sample.pdf"); IOUtils.copy(targetStream, response.getOutputStream()); } catch (Exception e) { LOG.error("Document Download Error", e.getMessage()); } } 获取stream并将其转换为pdf文件并在浏览器中显示相同的内容: router.get('/openfile', function(req, res, next) { console.log("get call"); request('http://localhost:8080/getFileContent', function […]

如何在同一个LAN上findSocket.IO服务器?

我正在开发一个连接同一networking上的设备的应用程序。 任何设备都可以作为服务器,我希望客户端能够自动find服务器,而无需用户手动input服务器的IP地址。 这是我打算这样做的: find客户端的IP,例如192.168.0.2 循环192.168.0。(0-> 255) 尝试连接所有这些IP,直到连接成功 这是正确的方式吗? 我可以做得更快吗? 在同一networking上的IP始终在xxx(0-> 255)范围内? 如果这是相关性,我正在使用Java和JavaScript(Node.js)。

Docker图像与基础图像混合

我想构build一个使用NodeJs和Java Runtime的docker镜像。 有可能find不同的docker文件,每个基地一个。 我如何使用两个基地来创build一个新的图像? 在这种情况下,我要运行一个angular度的应用程序,并在同一图像的春季应用程序。 有关如何拥有这样的要求的单个图像的任何提示? 是否有意义?

我怎么能检查它是否是一个12字节的String对象,MongoDB中的ObjectID?

我想检查一个正确的ObjectID来继续我的代码。 我在NodeJS上,我不想得到这个错误: 错误:传入的参数必须是12个字节的单个string或24个hex字符的string 其实我有这些testing: if (!user.id || !user.id.match("/^[0-9a-fA-f]{24}$") || !typeof(user.id) === 'string') { console.log("user id is required !") return callback("user id is required !") } 对于24个hex字符的string,我得到这个正则expression式: !user.id.match("/^[0-9a-fA-f]{24}$") 我正在检查它是否是一个12字节的string: !typeof(user.id) === 'string' 我应该如何为12个字节添加validation? 有什么想法吗?

Selenium-Webdriver NodeJS相当于Java代码的DesiredCapabilities

我已经在selenium-webdriver位于这里( http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_Capabilities.html )search文档(这里没有什么) 我找不到从Java到NodeJS的等效代码。 这里是JAVA中的代码(我从这里复制testingconfiguration选项部分, https://github.com/zalando/zalenium/blob/master/docs/usage_examples.md#initial-setup ) DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX); desiredCapabilities.setCapability(CapabilityType.PLATFORM, Platform.LINUX); desiredCapabilities.setCapability("name", "myTestName"); 特别是我想设置能力“名称”,所以我可以用Zalenium命名我的testing。 我如何在NodeJS中做到这一点? 这是我目前的selnium webdriver代码,它的工作(和编辑删除敏感信息),但不设置testing名称。 我试过这个.withCapabilities(webdriver.Capabilities.chrome(),{“name”,“chrometest”}),它编译,但我不认为它做什么? //Run using this project (https://github.com/qmu/dockerfiles/blob/master/src/selenium-webdriver-node/example/bin/run) "use strict"; const webdriver = require('selenium-webdriver'), By = webdriver.By, until = webdriver.until, test = require('selenium-webdriver/testing'); //const expect = require('expect.js'); const assert = require('assert'); var driver = new […]

从应用程序更新vcap env

有没有办法在比较更新vcap env port服务的代码从我的应用程序,可以说我想改变port为12345 eg { "VCAP_SERVICES": { "mongodb": [ { "credentials": { "dbname": "ztmvvvmtrz", "hostname": "13.15.241.29", "password": "abzArl7AsssseKpi", "port": "22241", 而尝试cf set-env其更新user provided env ,并不能够帮助… java / node.js上的一些例子将伟大

Maven-Plugin:无法运行任务'纱线'

构build项目并运行frontend-maven-plugin会导致运行任务失败。 眼镜: Node.js 6.11.4 npm 3.10.10 纱线1.2.1 Maven 3.3.9(3.5.0) 操作系统:Windows 10 64位和Ubuntu 16.10 这就是日志的样子: [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.3:yarn (frontend: execute yarn install) on project zanata-frontend: Failed to run task: 'yarn ' failed. (error code 1) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.3:yarn (frontend: execute yarn install) on project zanata-frontend: Failed to […]

如何select最佳自动化与selenium工具组合

这可能是基于意见的问题,但我真的很困惑select自动化工具组合。 到目前为止,我一直在使用Selenium webdriver,maven和Java来构build自动化框架。 这似乎完全正常工作。 现在有一天我觉得很多自动化工程师WebdriverJS使用WebdriverJS , WebdriverIO , WebdriverIO等等。 有人告诉我,如果使用WebdriverJS / WebdriverIO / WebdriverJS构build自动化框架,那么执行速度将比Java快。 我知道我应该根据自己的需求来select工具,但是同时我觉得我们不能在某些网站中使用WebdriverJS / WebdriverIO / WebdriverIO在这种网站中所有的元素都必须被xpath为dynamic改变class / id大多数元素。 所以,如果任何人都可以给我提示哪些工具select哪种网站,那么这将是非常有帮助的。 即对于AngularJS网站Node.Js对于selenium自动化Node.Js是很好的。

对成功方法改造空值响应

我正在按照YouTube中的这个教程进行Retrofit,用于在发布请求中发送对象,但在模拟器上遇到onResponse方法为空响应的错误 。 问题: 主要活动: public class MainActivity extends AppCompatActivity { private EditText mName, mEmail, mAge, mTopics; private Button mButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mName = findViewById(R.id.editText); mEmail = findViewById(R.id.editText2); mAge = findViewById(R.id.editText3); mTopics = findViewById(R.id.editText4); mButton = findViewById(R.id.button); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { User user = new […]