资源简介
diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具diffy工具
代码片段和文件信息
import java.net.InetSocketAddress;
import java.io.IOException;
import java.io.OutputStream;
import java.util.function.Function;
import java.util.stream.Stream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class ExampleServers {
public static void main(String[] args) throws Exception {
int primary = Integer.parseInt(args[0]);
int secondary = Integer.parseInt(args[1]);
int candidate = Integer.parseInt(args[2]);
Thread p = new Thread(() -> bind(primary x -> x.toLowerCase()));
Thread s = new Thread(() -> bind(secondary x -> x.toLowerCase()));
Thread c = new Thread(() -> bind(candidate x -> x.toUpperCase()));
p.start();
s.start();
c.start();
while(true){
Thread.sleep(10);
}
}
public static void bind(int port Function lambda) {
try {
HttpServer server = HttpServer.create(new InetSocketAddress(port) 0);
server.createContext(
“/json“
new Handler(
“{\“name\“:\“%s\“ \“timestamp\“:\“%s\“}“
“application/json“
lambda));
server.createContext(
“/html“
new Handler(
“%s %s “
“text/html“
lambda));
server.setExecutor(null);
server.start();
} catch (Exception exception) {
System.err.println(“!!!failed to start!!!“);
}
}
}
class Handler implements HttpHandler {
private String template;
private String contentType;
private Function lambda;
public Handler(String template String contentType Function lambda) {
super();
this.template = template;
this.contentType = contentType;
this.lambda = lambda;
}
@Override
public void handle(HttpExchange t) throws IOException {
String name = lambda.apply(t.getRequestURI().getQuery());
String response = String.format(template name System.currentTimeMillis());
System.out.println(response);
t.getResponseHeaders().add(“Content-Type“ contentType);
t.sendResponseHeaders(200 response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-31 02:41 diffy-master\
文件 200 2018-03-31 02:41 diffy-master\.gitignore
文件 436 2018-03-31 02:41 diffy-master\.travis.yml
文件 373 2018-03-31 02:41 diffy-master\BUILD
文件 526 2018-03-31 02:41 diffy-master\Dockerfile
文件 11358 2018-03-31 02:41 diffy-master\LICENSE
文件 6174 2018-03-31 02:41 diffy-master\README.md
文件 4627 2018-03-31 02:41 diffy-master\build.sbt
目录 0 2018-03-31 02:41 diffy-master\example\
文件 2610 2018-03-31 02:41 diffy-master\example\ExampleServers.java
文件 790 2018-03-31 02:41 diffy-master\example\run.sh
目录 0 2018-03-31 02:41 diffy-master\project\
文件 19 2018-03-31 02:41 diffy-master\project\build.properties
文件 607 2018-03-31 02:41 diffy-master\project\plugins.sbt
文件 1184 2018-03-31 02:41 diffy-master\sbt
文件 4387 2018-03-31 02:41 diffy-master\scalast
目录 0 2018-03-31 02:41 diffy-master\src\
目录 0 2018-03-31 02:41 diffy-master\src\main\
目录 0 2018-03-31 02:41 diffy-master\src\main\resources\
文件 92 2018-03-31 02:41 diffy-master\src\main\resources\BUILD
目录 0 2018-03-31 02:41 diffy-master\src\main\resources\templates\
文件 2609 2018-03-31 02:41 diffy-master\src\main\resources\templates\cron_report.mustache
文件 12330 2018-03-31 02:41 diffy-master\src\main\resources\templates\dashboard.mustache
目录 0 2018-03-31 02:41 diffy-master\src\main\scala\
文件 292 2018-03-31 02:41 diffy-master\src\main\scala\BUILD
目录 0 2018-03-31 02:41 diffy-master\src\main\scala\com\
目录 0 2018-03-31 02:41 diffy-master\src\main\scala\com\twitter\
目录 0 2018-03-31 02:41 diffy-master\src\main\scala\com\twitter\diffy\
文件 6486 2018-03-31 02:41 diffy-master\src\main\scala\com\twitter\diffy\ApiController.scala
文件 259 2018-03-31 02:41 diffy-master\src\main\scala\com\twitter\diffy\BUILD
文件 4020 2018-03-31 02:41 diffy-master\src\main\scala\com\twitter\diffy\DiffyServiceModule.scala
............此处省略87个文件信息
- 上一篇:VxWorks共享库入门教程
- 下一篇:我国NO7信令网与电话网对应关系
相关资源
- ASCII码与16进制之间的转化工具
- IEEE32位浮点数转换工具含源码
- NAT类型测试工具-NatTypeTester
- MDXimporter导3dMax插件.zip 工具
- 文件夹目录树列表小工具!实用
- windows下fastboot工具
- 侦测ip端口小工具tcping linux版
- 超链接提取工具 网站链接抓取器 提取
- MTracer-正则表达式测试工具
- QT编写的串口设备调试工具终极版
- 解除迅雷BT版权限制小工具.zip
- MSI安装程序强力卸载工具
- 窗口透明化工具,可任意调节当前窗
- txt关键词提取工具
- QQ批量登陆工具
- 单片机普中PZISP烧录工具
- hex转coe工具
- UltraEdit、UltraCompare激活工具
- TCP报文发送接收测试工具
- 支持复制粘贴的远程登录工具mstsc
- 嵌入式linux下截图工具gsnap移植源码
- zwloaddriver
- 个人资料转移工具————方便的文
- 文件校验工具MD5SHA1SHA210.2TOKYOHOT含源码
- 正版Landesk卸载工具
- 股票查询工具(含前端页面)
- M3u8视频工具
- 还原卡破解工具集
- USR-TCP232-Test.exe
- LTE频点计算工具
评论
共有 条评论