我试过与其他一些文本分开,它在那里工作正常但不在这里.谁能告诉我这里做错了什么?
private static String fileName = "jjjj.txt";
private static String userName = "xxxx";
private static String password = "yyyy";
public static void main(String args[]){
String info = "UserName" +"|"+ userName + "|" + password + "|" + fileName;
String tempStr[] = info.split("|");
System.out.println(tempStr[0]);
System.out.println(tempStr[1]);
System.out.println(tempStr[2]);
System.out.println(tempStr[3]);
}
Run Code Online (Sandbox Code Playgroud)
我得到输出为:
U
s
e
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能得到输出:
UserName
xxxx
yyyy
jjjj.txt
Run Code Online (Sandbox Code Playgroud) 我的代码如下.当请求到来时,服务器创建两个线程(生产者 - 消费者模式):
...
while(true) {
Socket clientSocket = server.accept();
System.out.println("Got connection!");
Thread consumerThread = new Thread(new ConsumerThread(sharedQueue, clientSocket));
Thread producerThread = new Thread(new ProducerThread(sharedQueue, clientSocket));
consumerThread.start();
producerThread.start();
}
...
Run Code Online (Sandbox Code Playgroud)
消费者线程读取客户端发送的内容和生产者线程的响应.消费者:
@Override
public void run() {
try {
while (true) {
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
// read, do actions
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
制片人:
@Override …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个小巧轻便的基于PHP的工作表系统.我在网上知道我能找到很多,但这些对我来说太过分了.
我有桌子:
ID
date
user_name
workplace1_am
workplace1_pm
workplace2_am
workplace2_pm
Run Code Online (Sandbox Code Playgroud)
对于当前月份和当前日期,我解决了问题.
现在我需要从下个月的表中获取数据:
SELECT * FROM table WHERE ...
Run Code Online (Sandbox Code Playgroud) 我得到RuntimeException
枚举类型可能无法实例化
我不知道为什么.我想要的是用一个整数值来标识一年,就像我有9所以其他方法的年份是2006年.代码:
public class P21Make {
enum Catalog {
year2005(9),year2006(12),year2007(15),year2008(18),
year2009(21),year2010(23),year2011(25),year2012(28),
year2013(31),year2014(33),year2015(36),year2016(39),
year2017(42),year2018(45),year2019(48),year2020(51);
private int id;
Catalog(int c){
this.id=c;
}
}
public P21Make() {
Catalog c = new Catalog(9); // The Exception
}
}
Run Code Online (Sandbox Code Playgroud) 我对 Java 8 中的流很陌生,所以我的方法可能是错误的。
我有 2 个对象如下
object1 {
BigDecimal amount;
Code1 code1;
Code2 code2;
Code3 code3;
String desc;
}
object2 {
BigDecimal amount;
Code1 code1;
Code2 code2;
Code3 code3;
}
Run Code Online (Sandbox Code Playgroud)
所以我想收集 code1 && code2 && code3 相同的所有 object1,然后将数量相加将其添加到 object2 列表中。
我没有代码来做到这一点......我想编写一个代码来完成这项工作我正在尝试从http://docs.oracle.com/javase/tutorial/collections/interfaces/map.html实现一些东西
或者按部门计算所有工资的总和:
// Compute sum of salaries by department
Map<Department, Integer> totalByDept = employees.stream()
.collect(Collectors.groupingBy(Employee::getDepartment,
Collectors.summingInt(Employee::getSalary)));
Run Code Online (Sandbox Code Playgroud) 循环 n 个项目(如数组)然后循环 (n-1) 然后循环 (n-2) 等等的算法的复杂性是多少 像:
Loop(int[] array) {
for (int i=0; i<array.Length; i++) {
//do some thing
}
}
Main() {
Loop({1, 2, 3, 4});
Loop({1, 2, 3});
Loop({1, 2});
Loop({1});
//What the complexity of this code.
}
Run Code Online (Sandbox Code Playgroud)
前面的程序的复杂度是多少?
我正在使用以下配置的笔记本电脑.处理器:Intel(R)Core(TM)i5-4300U CPU @ 1.90GHz 2.49GHz RAM:8GB系统类型:64位OS,基于x64的处理器
Windows Edition:Windows 8.2 Enterprise
当我阅读有关CPU架构的内容时,我想知道计算机中遵循的CPU架构是什么?
我是java 8的新手并且学习lambda表达式.
我有一个界面.
Configuration.java
package com.raghu.example;
import java.util.Map;
public interface Configuration {
public Map<String,String> getPayload();
}
Run Code Online (Sandbox Code Playgroud)
Impl用于接口:ConfigurationImpl.java
package com.raghu.example;
import java.util.HashMap;
import java.util.Map;
public class ConfigurationImpl implements Configuration {
@Override
public Map<String, String> getPayload() {
Map<String,String> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
//return null;
return map;
}
}
Run Code Online (Sandbox Code Playgroud)
我的主程序:Sample.java
package com.raghu.example;
import java.util.Optional;
public class Sample {
Configuration config;
/*
* if config is null, return "";
* if config.getPaylaod is null, return "";
* if config.payload is …Run Code Online (Sandbox Code Playgroud) 我在运行 Node.js 服务器时收到此错误:
Error: Not Found
at C:\wamp\www\scope-leads-node-master\MyApp\app.js:30:13
at Layer.handle [as handle_request] (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:312:13)
at C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:280:7
at Function.process_params (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:330:12)
at next (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:271:10)
at C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:618:15
at next (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:256:14)
at Function.handle (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:176:3)
at router (C:\wamp\www\scope-leads-node-master\MyApp\node_modules\express\lib\router\index.js:46:12)
Run Code Online (Sandbox Code Playgroud)
var express = require('express');
var 路径 = require('路径');
var favicon = require('serve-favicon');
var logger = require('摩根');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var 路线 = require('./routes/index');
var users = require('./routes/users');
var 应用程序 = Express();
// 查看引擎设置
app.set('views', path.join(__dirname, 'views'));
app.set('视图引擎', '玉石');
// 将您的网站图标放入 … 我试图用crontab运行一个简单的Python脚本,但我无法让它工作.不使用Python时,我可以在crontab中运行一个简单的程序.以下是我在Crontab文件中运行的行:
* * * * * echo “cron test” >> /home/ftpuser/dev/mod_high_lows/hello.txt
Run Code Online (Sandbox Code Playgroud)
我也可以直接从命令行运行这个python脚本testit.py.这是我输出csv文件的testit.py文件.
#!/usr/bin/env python
import f_file_handling
_data = [(12,15,17)]
f_file_handling.csv_out('my_file_test',_data)
Run Code Online (Sandbox Code Playgroud)
上面的文件有我做的功能,但是我知道它有效,因为当我从命令行运行testit.py时它会像我期望的那样:
python testit.py
Run Code Online (Sandbox Code Playgroud)
所以我让Crontab自己动手,并且testit.py文件可以自行运行,然后我尝试用Crontab运行testit.py文件.我确实使用命令使testit.py文件可执行:
chmod +x testit.py
Run Code Online (Sandbox Code Playgroud)
我看到它的可执行文件,因为当我在正确的目录中时,我的linux命令窗口中的文件显示为绿色.现在在我用来运行早期Crontab测试的同一个Crontab文件中,我添加了以下行:
* * * * * /home/ftpuser/dev/mod_high_lows/testit.py
Run Code Online (Sandbox Code Playgroud)
是的,我想要每分钟执行一次,只是尝试运行最简单的测试,以使Crontab和Python协同工作.
这是我正在使用的:
Ubuntu 14.04.2 LTS(GNU/Linux 3.13.0-52-generic x86_64)
Python 2.7
以上是在我设置的linux服务器上.
你看我的testit.py文件顶部的shebang行,从我的研究中看这应该有效.
至于我的testit.py python文件,我在windows机器上写了它,然后将它传送到服务器,但是当crontab和python不能一起工作时,我还使用Nano文本编辑器从Linux命令窗口编码该文件,但是尝试通过Crontab运行testit.py文件时没有任何区别.因此,即使我直接在Linux服务器上编写testit.py代码也不会运行(以防万一Windows在我的文件中创建隐藏字符).