mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-29 19:56:44 +08:00
添加获取当前文件夹名称方法
This commit is contained in:
parent
e83dd64c74
commit
f96e4b5199
@ -3582,6 +3582,7 @@ public class FileUtil {
|
||||
/**
|
||||
* 获取当前文件夹, 不管是否在jar包中都会返回文件夹的路径
|
||||
* class在jar包中返回jar所在文件夹,class不在jar中返回文件夹目录
|
||||
* jdk中的类不能使用此方法
|
||||
*/
|
||||
public static String getCurrentDir(Class clazz) {
|
||||
String currentDir = null;
|
||||
|
@ -1,23 +1,31 @@
|
||||
package cn.hutool.core.io.file;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import lombok.Data;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TailerTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void tailTest() {
|
||||
FileUtil.tail(FileUtil.file("e:/tail.txt"), CharsetUtil.CHARSET_GBK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void tailWithLinesTest() {
|
||||
Tailer tailer = new Tailer(FileUtil.file("f:/test/test.log"), Tailer.CONSOLE_HANDLER, 2);
|
||||
tailer.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void tailTest() {
|
||||
FileUtil.tail(FileUtil.file("e:/tail.txt"), CharsetUtil.CHARSET_GBK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void tailWithLinesTest() {
|
||||
Tailer tailer = new Tailer(FileUtil.file("f:/test/test.log"), Tailer.CONSOLE_HANDLER, 2);
|
||||
tailer.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testDir() {
|
||||
System.out.println(FileUtil.getCurrentDir(FileUtil.class));
|
||||
System.out.println(FileUtil.getCurrentDir(Data.class));
|
||||
System.out.println(FileUtil.getCurrentDir(Test.class));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user