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