io.advantageous.boon.core.IO.read()方法的使用及代码示例

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

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

IO.read介绍

暂无

代码示例

代码示例来源:origin: advantageous/qbit

private static String readErrorResponseBodyDoNotDie(HttpURLConnection http, int status, String charset) {
  InputStream errorStream = http.getErrorStream();
  if (errorStream != null) {
    String error = charset == null ? IO.read(errorStream) :
        IO.read(errorStream, charset);
    return error;
  } else {
    return "";
  }
}

代码示例来源:origin: advantageous/qbit

private static String readResponseBody(HttpURLConnection http, String charset) throws IOException {
  if (charset != null) {
    return IO.read(http.getInputStream(), charset);
  } else {
    return IO.read(http.getInputStream());
  }
}

代码示例来源:origin: advantageous/qbit

private static String readErrorResponseBody(HttpURLConnection http, int status, String charset) {
  InputStream errorStream = http.getErrorStream();
  if (errorStream != null) {
    String error = charset == null ? IO.read(errorStream) :
        IO.read(errorStream, charset);
    return Exceptions.die(String.class, "STATUS CODE =" + status + "\n\n" + error);
  } else {
    return Exceptions.die(String.class, "STATUS CODE =" + status);
  }
}

代码示例来源:origin: advantageous/qbit

public String getWebPageContents() {
  if (webPageContents == null || webPageContents.isEmpty()) {
    final String htmlPageLocationInitial = getHtmlPageLocation();
    final String pageLocation;
    pageLocation = htmlPageLocationInitial.startsWith("/") ?
        htmlPageLocationInitial.substring(1, htmlPageLocationInitial.length()) :
        htmlPageLocationInitial;
    webPageContents = IO.read(
        Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream(pageLocation)
    );
  }
  return webPageContents;
}

代码示例来源:origin: advantageous/qbit

/**
 * Reads the readConfig file, which can be a classpath or file system resource.
 *
 * @param serviceName the name of the service to load
 * @return service config
 */
public static MicroserviceConfig readConfig(final String serviceName) {
  final Logger logger = LoggerFactory.getLogger(MicroserviceConfig.class);
  if (new File(resourceLocation).exists()) {
    final String json = IO.read(resourceLocation);
    return JsonFactory.fromJson(json, MicroserviceConfig.class);
  } else if (resourceLocationEnv != null && new File(resourceLocationEnv).exists()) {
    final String json = IO.read(resourceLocationEnv);
    return JsonFactory.fromJson(json, MicroserviceConfig.class);
  } else {
    logger.info("Reading config from classpath as it is not found on file system");
    final String qbitEnv = System.getenv("QBIT_ENV");
    final String resourceLocationOnClasspath =
        qbitEnv != null && !qbitEnv.isEmpty() ? serviceName + "_" + qbitEnv + ".json" :
            serviceName + ".json";
    final String json = IO.read(Thread.currentThread().getContextClassLoader()
        .getResourceAsStream(resourceLocationOnClasspath));
    return JsonFactory.fromJson(json, MicroserviceConfig.class);
  }
}

代码示例来源:origin: io.advantageous.boon/boon-reflekt

public static CharBuf read( InputStream inputStream, CharBuf charBuf, Charset charset, int bufSize, char[] copyBuf ) {
  try ( Reader reader = new InputStreamReader( inputStream, charset ) ) {
    return read( reader, charBuf, bufSize, copyBuf );
  } catch ( Exception ex ) {
    return Exceptions.handle( CharBuf.class, ex );
  }
}

代码示例来源:origin: io.advantageous.boon/boon-reflekt

public static String read( File file ) {
  try ( Reader reader = new FileReader( file ) ) {
    return read( reader );
  } catch ( Exception ex ) {
    return Exceptions.handle( String.class, ex );
  }
}

代码示例来源:origin: com.github.advantageous/boon-reflekt

public static String read( InputStream inputStream, Charset charset ) {
  try ( Reader reader = new InputStreamReader( inputStream, charset ) ) {
    return read( reader );
  } catch ( Exception ex ) {
    return Exceptions.handle( String.class, ex );
  }
}

代码示例来源:origin: com.github.advantageous/boon-reflekt

public static String read( File file ) {
  try ( Reader reader = new FileReader( file ) ) {
    return read( reader );
  } catch ( Exception ex ) {
    return Exceptions.handle( String.class, ex );
  }
}

代码示例来源:origin: com.github.advantageous/boon-reflekt

public static String readCharBuffer( InputStream inputStream, Charset charset ) {
  try ( Reader reader = new InputStreamReader( inputStream, charset ) ) {
    return read( reader );
  } catch ( Exception ex ) {
    return Exceptions.handle( String.class, ex );
  }
}

代码示例来源:origin: com.github.advantageous/boon-reflekt

public static CharBuf read( InputStream inputStream, CharBuf charBuf ) {
  try ( Reader reader = new InputStreamReader( inputStream ) ) {
    return read( reader, charBuf );
  } catch ( Exception ex ) {
    return Exceptions.handle( CharBuf.class, ex );
  }
}

代码示例来源:origin: com.github.advantageous/boon-reflekt

public static CharBuf read( InputStream inputStream, CharBuf charBuf, Charset charset ) {
  try ( Reader reader = new InputStreamReader( inputStream, charset ) ) {
    return read( reader, charBuf );
  } catch ( Exception ex ) {
    return Exceptions.handle( CharBuf.class, ex );
  }
}

代码示例来源:origin: io.advantageous.boon/boon-util

private static String readErrorResponseBody( HttpURLConnection http, int status, String charset ) {
  InputStream errorStream = http.getErrorStream();
  if ( errorStream != null ) {
    String error = charset == null ? IO.read( errorStream ) :
        IO.read( errorStream, charset );
    return Exceptions.die( String.class, "STATUS CODE =" + status + "\n\n" + error );
  } else {
    return Exceptions.die( String.class, "STATUS CODE =" + status );
  }
}

代码示例来源:origin: com.github.advantageous/boon-json

@Override
public  <T> T parse( Class<T> type, InputStream input ) {
  if (copyBuf==null) {
    copyBuf = new char[bufSize];
  }
  fileInputBuf = IO.read( input, fileInputBuf, charset, bufSize, copyBuf );
  return parse( type, fileInputBuf.readForRecycle() );
}

代码示例来源:origin: io.gatling.advantageous.boon/boon-json

@Override
public  <T> T parse( Class<T> type, Reader reader ) {
  if (copyBuf==null) {
    copyBuf = new char[bufSize];
  }
  fileInputBuf = IO.read( reader, fileInputBuf, bufSize, copyBuf );
  return parse( type, fileInputBuf.readForRecycle() );
}

代码示例来源:origin: io.gatling.advantageous.boon/boon-json

@Override
public  <T> T parse( Class<T> type, InputStream input, Charset charset ) {
  fileInputBuf = IO.read( input, fileInputBuf, charset, bufSize, copyBuf );
  return parse( type, fileInputBuf.readForRecycle() );
}

代码示例来源:origin: io.advantageous.boon/boon-json

@Override
public final <T> T parse( Class<T> type, InputStream input, Charset charset ) {
  if (copyBuf==null) {
    copyBuf = new char[bufSize];
  }
  charBuf = IO.read( input, charBuf, charset, bufSize, copyBuf );
  return parse( type, charBuf.readForRecycle() );
}

代码示例来源:origin: com.github.advantageous/boon-json

@Override
public  Object parse(  Reader reader ) {
  if (copyBuf==null) {
    copyBuf = new char[bufSize];
  }
  fileInputBuf = IO.read ( reader, fileInputBuf, bufSize, copyBuf );
  return parse( fileInputBuf.readForRecycle() );
}

代码示例来源:origin: com.github.advantageous/boon-json

@Override
public final <T> T parse( Class<T> type, Reader reader ) {
  if (copyBuf==null) {
    copyBuf = new char[bufSize];
  }
  charBuf = IO.read( reader, charBuf, bufSize, copyBuf );
  return parse( type, charBuf.readForRecycle() );
}

代码示例来源:origin: com.github.advantageous/boon-json

@Override
public final <T> T parse( Class<T> type, InputStream input ) {
  if (copyBuf==null) {
    copyBuf = new char[bufSize];
  }
  charBuf = IO.read( input, charBuf, this.charset, bufSize, copyBuf );
  return parse( type, charBuf.readForRecycle() );
}

相关文章