本文整理汇总了Java中org.eclipse.jetty.util.IO类的典型用法代码示例。如果您正苦于以下问题:Java IO类的具体用法?Java IO怎么用?Java IO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IO类属于org.eclipse.jetty.util包,在下文中一共展示了IO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DirectNIOBuffer
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
/**
* @param file
*/
public DirectNIOBuffer(File file) throws IOException
{
super(READONLY,NON_VOLATILE);
FileInputStream fis = null;
FileChannel fc = null;
try
{
fis = new FileInputStream(file);
fc = fis.getChannel();
_buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
setGetIndex(0);
setPutIndex((int)file.length());
_access=IMMUTABLE;
}
finally
{
if (fc != null) try {fc.close();} catch (IOException e){LOG.ignore(e);}
IO.close(fis);
}
}
示例2: getInputStream
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
public InputStream getInputStream()
throws java.io.IOException
{
checkConnection();
if (!_urlString.endsWith("!/"))
return new FilterInputStream(super.getInputStream())
{
@Override
public void close() throws IOException {this.in=IO.getClosedStream();}
};
URL url = new URL(_urlString.substring(4,_urlString.length()-2));
InputStream is = url.openStream();
return is;
}
示例3: writeTo
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
/**
* @param out
* @param start First byte to write
* @param count Bytes to write or -1 for all of them.
*/
public void writeTo(OutputStream out,long start,long count)
throws IOException
{
InputStream in = getInputStream();
try
{
in.skip(start);
if (count<0)
IO.copy(in,out);
else
IO.copy(in,out,count);
}
finally
{
in.close();
}
}
示例4: getInputStream
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
public InputStream getInputStream()
throws java.io.IOException
{
checkConnection();
if (!_urlString.endsWith("!/"))
return new FilterInputStream(super.getInputStream())
{
@Override
public void close() throws IOException {this.in=IO.getClosedStream();}
};
URL url = new URL(_urlString.substring(4,_urlString.length()-2));
InputStream is = url.openStream();
return is;
}
示例5: FavIconHandler
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
public FavIconHandler() {
byte[] bytes;
try {
URL fav = this.getClass().getClassLoader().getResource("favicon.ico");
Resource r = Resource.newResource(fav);
bytes = IO.readBytes(r.getInputStream());
} catch (IOException e) {
log.warn("Could not load favicon", e);
bytes = null;
}
favicon = bytes;
}
示例6: produceStartScript
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
private String produceStartScript(String serviceName) {
final URL startStopResource = getClass().getResource("startstop.sh");
String ss = null;
try {
ss = IO.toString(startStopResource.openStream());
} catch (IOException e) {
throw new RuntimeException(e);
}
ss = String.format(ss, serviceName, getWarLocation().getAbsolutePath());
return ss;
}
示例7: shutdown
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
private void shutdown() {
if(jettyManager != null) {
jettyManager.shutdown();
}
if(jettyWorkDirectory != null) {
IO.delete(jettyWorkDirectory);
}
}
示例8: copyTo
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
public void copyTo(File destination)
throws IOException
{
if (isDirectory())
{
IO.copyDir(getFile(),destination);
}
else
{
if (destination.exists())
throw new IllegalArgumentException(destination+" exists");
IO.copy(getFile(),destination);
}
}
示例9: ClassPathResource
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
/**
* Specifies the classpath path containing the resource
*/
public ClassPathResource(String path) {
this.path = path;
InputStream is = LauncherUtils.getSeleniumResourceAsStream(path);
if (is != null) {
os = new ByteArrayOutputStream();
try {
IO.copy(is, os);
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例10: doGet
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String body = IO.toString(request.getInputStream(), Charsets.UTF_8.displayName());
logger.debug("received {} request: {}\n Body: '{}'", request.getMethod(), request.getRequestURI(), body);
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().print(this.message);
}
示例11: doGet
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String body = IO.toString(request.getInputStream(), Charsets.UTF_8.displayName());
logger.debug("received {} request: {}\n Body: '{}'", request.getMethod(), request.getRequestURI(), body);
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println(body);
}
示例12: handleRequest
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
String body = IO.toString(request.getInputStream(), Charsets.UTF_8.displayName());
logger.debug("received {} request: {}\n Body: '{}'", request.getMethod(), request.getRequestURI(), body);
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().print("Hello World!");
}
示例13: doGet
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String body = IO.toString(request.getInputStream(), Charsets.UTF_8.displayName());
logger.debug("received {} request: {}\n Body: '{}'", request.getMethod(), request.getRequestURI(), body);
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
return;
}
示例14: doPost
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String body = IO.toString(request.getInputStream(), Charsets.UTF_8.displayName());
logger.debug("received {} request: {}\n Body: '{}'", request.getMethod(), request.getRequestURI(), body);
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
return;
}
示例15: doPost
import org.eclipse.jetty.util.IO; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String body = IO.toString(request.getInputStream(), Charsets.UTF_8.displayName());
logger.debug("received {} request: {}\n Body: '{}'", request.getMethod(), request.getRequestURI(), body);
this.receivedAlerts.add(JsonUtils.toObject(JsonUtils.parseJsonString(body), Alert.class));
response.setContentType("text/html;charset=utf-8");
response.setStatus(this.responseCode);
response.getWriter().close();
}