Expectit-是纯Java1.6+实现的Expect工具。简单易用和可扩展,全新编写无需依赖第三方库,使用管道和非堵塞API基于NIO实现。
Mave:
<depedecy> <groupId>et.sf.expectit</groupId> <artifactId>expectit-core</artifactId> <versio>0.3.0</versio></depedecy>使用方法:
// the stream from where you read your iput dataIputStream iputStream = ...;// the stream to where you sed commadsOutputStream outputStream = ...;Expect expect = ew ExpectBuilder() .withIputs(iputStream) .withOutput(outputStream) .build();expect.sedLie("commad").expect(cotais("strig"));Result result = expect.expect(regexp("(.*)--?--(.*)"));// accessig the matchig groupStrig group = result.group(2);











评论