Exemplo n.º 1
0
  @Test
  public void pathUtilTest() throws IOException {

    LOG.info(Files.isDirectory(Paths.get("/tmp/test")) == true ? "True " : "False");
    LOG.info(Files.exists(Paths.get("/tmp/test")) == true ? "True " : "False");
    LOG.info(Files.isWritable(Paths.get("/tmp/test").getParent()) == true ? "True " : "False");

    try {
      LOG.info(CrawlerUtils.getResourcePath("config"));
      LOG.info(CrawlerUtils.getResourcePath(""));
      LOG.info(CrawlerUtils.getCurrentBuildPath());
    } catch (Exception e) {
      LOG.debug(e.toString());
    }
  }
Exemplo n.º 2
0
 @Test
 public void iso88599TOeuckr() throws IOException {
   Stream<Path> s = Files.list(new File(CrawlerUtils.getResourcePath("convert")).toPath());
   Iterator<Path> iter = s.iterator();
   while (iter.hasNext()) {
     Path p = iter.next();
     LOG.info(
         new String(p.getFileName().toString().getBytes("ISO-8859-1"), Charset.forName("euc-kr")));
     String newName =
         new String(p.getFileName().toString().getBytes("ISO-8859-1"), Charset.forName("euc-kr"));
     p.toFile().renameTo(p.getParent().resolve(newName).toFile());
   }
   s.close();
   LOG.info(
       new String(
           "/tmp/firefox-downloads/hello".getBytes("ISO-8859-1"), Charset.forName("euc-kr")));
 }
Exemplo n.º 3
0
 // @Test
 public void resourceName() {
   LOG.info(CrawlerUtils.getResourcePath("abcd.pdf"));
   LOG.info(CrawlerUtils.getResourcePath("/abcd.pdf"));
   assertTrue(
       CrawlerUtils.getResourcePath("abcd.pdf").equals(CrawlerUtils.getResourcePath("/abcd.pdf")));
 }