org.apache.jena.atlas.io.IO.asUTF8()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.jena.atlas.io.IO.asUTF8()方法的一些代码示例,展示了IO.asUTF8()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IO.asUTF8()方法的具体详情如下:
包路径:org.apache.jena.atlas.io.IO
类名称:IO
方法名:asUTF8

IO.asUTF8介绍

[英]Create an unbuffered reader that uses UTF-8 encoding
[中]创建使用UTF-8编码的无缓冲读取器

代码示例

代码示例来源:origin: apache/jena

  1. /** Create a print writer that uses UTF-8 encoding */
  2. static public PrintWriter asPrintWriterUTF8(OutputStream out) {
  3. return new PrintWriter(asUTF8(out));
  4. }

代码示例来源:origin: org.apache.jena/jena-base

  1. /** Create an buffered reader that uses UTF-8 encoding */
  2. static public BufferedReader asBufferedUTF8(InputStream in) {
  3. return new BufferedReader(asUTF8(in)) ;
  4. }

代码示例来源:origin: apache/jena

  1. /** Create an buffered reader that uses UTF-8 encoding */
  2. static public BufferedReader asBufferedUTF8(InputStream in) {
  3. return new BufferedReader(asUTF8(in)) ;
  4. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Create an buffered reader that uses UTF-8 encoding */
  2. static public BufferedReader asBufferedUTF8(InputStream in) {
  3. return new BufferedReader(asUTF8(in)) ;
  4. }

代码示例来源:origin: org.apache.jena/jena-base

  1. /** Create a print writer that uses UTF-8 encoding */
  2. static public PrintWriter asPrintWriterUTF8(OutputStream out) {
  3. return new PrintWriter(asUTF8(out));
  4. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Create a print writer that uses UTF-8 encoding */
  2. static public PrintWriter asPrintWriterUTF8(OutputStream out) {
  3. return new PrintWriter(asUTF8(out));
  4. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Read a whole stream as UTF-8
  2. *
  3. * @param in InputStream to be read
  4. * @return String
  5. * @throws IOException
  6. */
  7. public static String readWholeFileAsUTF8(InputStream in) throws IOException
  8. {
  9. // Don't buffer - we're going to read in large chunks anyway
  10. Reader r = asUTF8(in) ;
  11. return readWholeFileAsUTF8(r) ;
  12. }

代码示例来源:origin: apache/jena

  1. /** Read a whole stream as UTF-8
  2. *
  3. * @param in InputStream to be read
  4. * @return String
  5. * @throws IOException
  6. */
  7. public static String readWholeFileAsUTF8(InputStream in) throws IOException {
  8. // Don't buffer - we're going to read in large chunks anyway
  9. try ( Reader r = asUTF8(in) ) {
  10. return readWholeFileAsUTF8(r) ;
  11. }
  12. }

代码示例来源:origin: org.apache.jena/jena-base

  1. /** Read a whole stream as UTF-8
  2. *
  3. * @param in InputStream to be read
  4. * @return String
  5. * @throws IOException
  6. */
  7. public static String readWholeFileAsUTF8(InputStream in) throws IOException {
  8. // Don't buffer - we're going to read in large chunks anyway
  9. try ( Reader r = asUTF8(in) ) {
  10. return readWholeFileAsUTF8(r) ;
  11. }
  12. }

代码示例来源:origin: apache/jena

  1. /** Wrap in a general writer interface */
  2. static public AWriter wrapUTF8(OutputStream out) { return wrap(asUTF8(out)) ; }

代码示例来源:origin: org.apache.jena/jena-base

  1. /** Wrap in a general writer interface */
  2. static public AWriter wrapUTF8(OutputStream out) { return wrap(asUTF8(out)) ; }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Wrap in a general writer interface */
  2. static public AWriter wrapUTF8(OutputStream out) { return wrap(asUTF8(out)); }

代码示例来源:origin: apache/jena

  1. @Override
  2. public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
  3. {
  4. String method = request.getMethod();
  5. if ( !method.equals(HttpMethod.GET.asString())
  6. && !method.equals(HttpMethod.POST.asString())
  7. && !method.equals(HttpMethod.HEAD.asString()) )
  8. return ;
  9. response.setContentType(MimeTypes.Type.TEXT_PLAIN_UTF_8.asString()) ;
  10. ServletOps.setNoCache(response) ;
  11. ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024) ;
  12. try ( Writer writer = IO.asUTF8(bytes) ) {
  13. String reason = (response instanceof Response) ? ((Response)response).getReason() : null;
  14. handleErrorPage(request, writer, response.getStatus(), reason) ;
  15. writer.flush();
  16. response.setContentLength(bytes.size()) ;
  17. response.getOutputStream().write(bytes.toByteArray()) ;
  18. }
  19. }

代码示例来源:origin: org.apache.jena/jena-fuseki-core

  1. @Override
  2. public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
  3. {
  4. String method = request.getMethod();
  5. if ( !method.equals(HttpMethod.GET.asString())
  6. && !method.equals(HttpMethod.POST.asString())
  7. && !method.equals(HttpMethod.HEAD.asString()) )
  8. return ;
  9. response.setContentType(MimeTypes.Type.TEXT_PLAIN_UTF_8.asString()) ;
  10. ServletOps.setNoCache(response) ;
  11. ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024) ;
  12. try ( Writer writer = IO.asUTF8(bytes) ) {
  13. String reason = (response instanceof Response) ? ((Response)response).getReason() : null;
  14. handleErrorPage(request, writer, response.getStatus(), reason) ;
  15. writer.flush();
  16. response.setContentLength(bytes.size()) ;
  17. response.getOutputStream().write(bytes.toByteArray()) ;
  18. }
  19. }

代码示例来源:origin: apache/jena

  1. /** Make PeekReader where the input is UTF8 : BOM is removed */
  2. public static PeekReader makeUTF8(InputStream in) {
  3. // This is the best route to make a PeekReader because it avoids
  4. // chances of wrong charset for a Reader say.
  5. PeekReader pr ;
  6. if ( true ) {
  7. Reader r = IO.asUTF8(in) ;
  8. // This adds reader-level buffering
  9. pr = make(r) ;
  10. } else {
  11. // This is a bit slower - reason unknown.
  12. InputStreamBuffered in2 = new InputStreamBuffered(in) ;
  13. CharStream r = new InStreamUTF8(in2) ;
  14. pr = new PeekReader(r) ;
  15. }
  16. // Skip BOM.
  17. int ch = pr.peekChar() ;
  18. if ( ch == Chars.BOM )
  19. // Skip BOM
  20. pr.readChar() ;
  21. return pr ;
  22. }

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  1. /** Make PeekReader where the input is UTF8 : BOM is removed */
  2. public static PeekReader makeUTF8(InputStream in) {
  3. // This is the best route to make a PeekReader because it avoids
  4. // chances of wrong charset for a Reader say.
  5. PeekReader pr ;
  6. if ( true ) {
  7. Reader r = IO.asUTF8(in) ;
  8. // This adds reader-level buffering
  9. pr = make(r) ;
  10. } else {
  11. // This is a bit slower - reason unknown.
  12. InputStreamBuffered in2 = new InputStreamBuffered(in) ;
  13. CharStream r = new InStreamUTF8(in2) ;
  14. pr = new PeekReader(r) ;
  15. }
  16. // Skip BOM.
  17. int ch = pr.peekChar() ;
  18. if ( ch == Chars.BOM )
  19. // Skip BOM
  20. pr.readChar() ;
  21. return pr ;
  22. }

代码示例来源:origin: org.apache.jena/jena-base

  1. /** Make PeekReader where the input is UTF8 : BOM is removed */
  2. public static PeekReader makeUTF8(InputStream in) {
  3. // This is the best route to make a PeekReader because it avoids
  4. // chances of wrong charset for a Reader say.
  5. PeekReader pr ;
  6. if ( true ) {
  7. Reader r = IO.asUTF8(in) ;
  8. // This adds reader-level buffering
  9. pr = make(r) ;
  10. } else {
  11. // This is a bit slower - reason unknown.
  12. InputStreamBuffered in2 = new InputStreamBuffered(in) ;
  13. CharStream r = new InStreamUTF8(in2) ;
  14. pr = new PeekReader(r) ;
  15. }
  16. // Skip BOM.
  17. int ch = pr.peekChar() ;
  18. if ( ch == Chars.BOM )
  19. // Skip BOM
  20. pr.readChar() ;
  21. return pr ;
  22. }

相关文章