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

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

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

IO.readLines介绍

暂无

代码示例

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

  1. public static List<URI> readDnsConf() {
  2. final Logger logger = LoggerFactory.getLogger(DnsUtil.class);
  3. final boolean debug = logger.isDebugEnabled();
  4. final File file = new File(Sys.sysProp(QBIT_DNS_RESOLV_CONF, "/etc/resolv.conf"));
  5. if (file.exists()) {
  6. final List<String> lines = IO.readLines(file);
  7. if (debug) logger.debug("file contents {}", lines);
  8. return lines.stream().filter(line -> line.startsWith("nameserver"))
  9. .map(line ->
  10. {
  11. if (debug) logger.debug("file content line = {}", line);
  12. final String uriToParse = line.replace("nameserver ", "").trim();
  13. final String[] split = Str.split(uriToParse, ':');
  14. try {
  15. if (split.length == 1) {
  16. return new URI("dns", "", split[0], 53, "", "", "");
  17. } else if (split.length >= 2) {
  18. return new URI("dns", "", split[0], Integer.parseInt(split[1]), "", "", "");
  19. } else {
  20. throw new IllegalStateException("Unable to parse URI from /etc/resolv.conf");
  21. }
  22. } catch (URISyntaxException e) {
  23. throw new IllegalStateException("failed to convert to URI");
  24. }
  25. })
  26. .collect(Collectors.toList());
  27. } else {
  28. throw new IllegalStateException("" + file + " not found");
  29. }
  30. }

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

  1. public static List<String> readLines( InputStream is ) {
  2. try ( Reader reader = new InputStreamReader( is, DEFAULT_CHARSET ) ) {
  3. return readLines( reader );
  4. } catch ( Exception ex ) {
  5. return Exceptions.handle( List.class, ex );
  6. }
  7. }

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

  1. public static List<String> readLines( Reader reader ) {
  2. try ( BufferedReader bufferedReader = new BufferedReader( reader ) ) {
  3. return readLines( bufferedReader );
  4. } catch ( Exception ex ) {
  5. return Exceptions.handle( List.class, ex );
  6. }
  7. }

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

  1. public static List<String> readLines( InputStream is ) {
  2. try ( Reader reader = new InputStreamReader( is, DEFAULT_CHARSET ) ) {
  3. return readLines( reader );
  4. } catch ( Exception ex ) {
  5. return Exceptions.handle( List.class, ex );
  6. }
  7. }

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

  1. public static List<String> readLines( Reader reader ) {
  2. try ( BufferedReader bufferedReader = new BufferedReader( reader ) ) {
  3. return readLines( bufferedReader );
  4. } catch ( Exception ex ) {
  5. return Exceptions.handle( List.class, ex );
  6. }
  7. }

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

  1. public static List<String> readLines( File file ) {
  2. try ( FileReader reader = new FileReader( file ) ) {
  3. return readLines( reader );
  4. } catch ( Exception ex ) {
  5. return Exceptions.handle( List.class, ex );
  6. }
  7. }

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

  1. public static List<String> readLines( File file ) {
  2. try ( FileReader reader = new FileReader( file ) ) {
  3. return readLines( reader );
  4. } catch ( Exception ex ) {
  5. return Exceptions.handle( List.class, ex );
  6. }
  7. }

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

  1. private static List<String> readLines( String location, URI uri ) throws Exception {
  2. try {
  3. String path = location;
  4. path = getWindowsPathIfNeeded( path );
  5. FileSystem fileSystem = FileSystems.getFileSystem( uri );
  6. Path fsPath = fileSystem.getPath( path );
  7. //Paths.get()
  8. return Files.readAllLines( fsPath, DEFAULT_CHARSET );
  9. } catch ( ProviderNotFoundException ex ) {
  10. return readLines( uri.toURL().openStream() );
  11. }
  12. }

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

  1. private static List<String> readLines( String location, URI uri ) throws Exception {
  2. try {
  3. String path = location;
  4. path = getWindowsPathIfNeeded( path );
  5. FileSystem fileSystem = FileSystems.getFileSystem( uri );
  6. Path fsPath = fileSystem.getPath( path );
  7. //Paths.get()
  8. return Files.readAllLines( fsPath, DEFAULT_CHARSET );
  9. } catch ( ProviderNotFoundException ex ) {
  10. return readLines( uri.toURL().openStream() );
  11. }
  12. }

代码示例来源:origin: com.github.advantageous/qbit-service-discovery

  1. public static List<URI> readDnsConf() {
  2. final Logger logger = LoggerFactory.getLogger(DnsUtil.class);
  3. final boolean debug = logger.isDebugEnabled();
  4. final File file = new File(Sys.sysProp(QBIT_DNS_RESOLV_CONF, "/etc/resolv.conf"));
  5. if (file.exists()) {
  6. final List<String> lines = IO.readLines(file);
  7. if (debug) logger.debug("file contents {}", lines);
  8. return lines.stream().filter(line -> line.startsWith("nameserver"))
  9. .map(line ->
  10. {
  11. if (debug) logger.debug("file content line = {}", line);
  12. final String uriToParse = line.replace("nameserver ", "").trim();
  13. final String[] split = Str.split(uriToParse, ':');
  14. try {
  15. if (split.length==1) {
  16. return new URI("dns", "", split[0], 53, "", "", "");
  17. } else if (split.length >= 2){
  18. return new URI("dns", "", split[0], Integer.parseInt(split[1]), "", "", "");
  19. } else {
  20. throw new IllegalStateException("Unable to parse URI from /etc/resolv.conf") ;
  21. }
  22. } catch (URISyntaxException e) {
  23. throw new IllegalStateException("failed to convert to URI");
  24. }
  25. })
  26. .collect(Collectors.toList());
  27. } else {
  28. throw new IllegalStateException("" + file + " not found");
  29. }
  30. }

相关文章