private void deleteTablepathName(String Dirname,String LOCAL_NAME) { for (String parentPath : this.parentPaths) { String NamePathName; NamePathName = parentPath + File.separator + Dirname; List<String> namesTablePathNames = getTablePathNames(NamePathName); log.info("namesTablePathNames: "+namesTablePathNames); for (String nameTablePathName : namesTablePathNames) { //log.info("nameTablePathName: "+nameTablePathName); CleanUtil.deleleFilesOfDir(nameTablePathName, pmCleanParas.get(LOCAL_NAME)); } //log.info("success delete:"+Dirname); } } 需要在NamePathname的路径后面还要加上一格目录,齐总目录有三种可能,怎么用java代码写
时间: 2024-02-28 22:57:35 浏览: 15
你可以使用Java中的`File`类来实现在路径后面添加目录的功能。具体代码如下:
```
private void deleteTablepathName(String Dirname, String LOCAL_NAME) {
for (String parentPath : this.parentPaths) {
String NamePathName = parentPath + File.separator + Dirname + File.separator;
List<String> namesTablePathNames = getTablePathNames(NamePathName);
log.info("namesTablePathNames: " + namesTablePathNames);
for (String nameTablePathName : namesTablePathNames) {
CleanUtil.deleleFilesOfDir(nameTablePathName, pmCleanParas.get(LOCAL_NAME));
}
}
}
```
在这个代码中,我们使用`File.separator`来表示文件系统的分隔符,它会根据不同的操作系统自动选择相应的分隔符。同时,在`NamePathName`的末尾添加了一个`File.separator`,以保证它是一个目录而不是文件。
相关问题
c_double_p = POINTER(c_double) c_uint16_p = POINTER(c_uint16) lib = cdll.LoadLibrary(os.path.dirname(os.path.abspath(__file__))+'/Octree_python_lib.so') lib.new_vector.restype = c_void_p lib.new_vector.argtypes = [] lib.delete_vector.restype = None lib.delete_vector.argtypes = [c_void_p] lib.vector_size.restype = c_int lib.vector_size.argtypes = [c_void_p] lib.vector_get.restype = c_void_p lib.vector_get.argtypes = [c_void_p, c_int] lib.vector_push_back.restype = None lib.vector_push_back.argtypes = [c_void_p, c_int] lib.genOctreeInterface.restype = c_void_p lib.genOctreeInterface.argtypes = [c_void_p ,c_double_p,c_int] lib.Nodes_get.argtypes = [c_void_p,c_int] lib.Nodes_get.restype = POINTER(Node) lib.Nodes_size.restype = c_int lib.Nodes_size.argtypes = [c_void_p] lib.int_size.restype = c_int lib.int_size.argtypes = [c_void_p] lib.int_get.restype = c_int lib.int_get.argtypes = [c_void_p,c_int]
这段代码是用来加载一个名为 Octree_python_lib.so 的动态链接库,并定义了一些函数接口和函数参数的类型。下面是对每个定义的函数接口和参数类型的解释:
- c_double_p: 定义了一个指向 double 类型的指针。
- c_uint16_p: 定义了一个指向 uint16 类型的指针。
- lib = cdll.LoadLibrary(os.path.dirname(os.path.abspath(__file__))+'/Octree_python_lib.so'): 加载 Octree_python_lib.so 动态链接库,并将其赋值给 lib 变量。
- lib.new_vector: 函数接口,返回类型为 c_void_p,无参数。
- lib.delete_vector: 函数接口,返回类型为 None,参数为 c_void_p。
- lib.vector_size: 函数接口,返回类型为 c_int,参数为 c_void_p。
- lib.vector_get: 函数接口,返回类型为 c_void_p,参数为 c_void_p 和 c_int。
- lib.vector_push_back: 函数接口,返回类型为 None,参数为 c_void_p 和 c_int。
- lib.genOctreeInterface: 函数接口,返回类型为 c_void_p,参数为 c_void_p、c_double_p 和 c_int。
- lib.Nodes_get: 函数接口,返回类型为指向 Node 类型的指针 (POINTER(Node)),参数为 c_void_p 和 c_int。
- lib.Nodes_size: 函数接口,返回类型为 c_int,参数为 c_void_p。
- lib.int_size: 函数接口,返回类型为 c_int,参数为 c_void_p。
- lib.int_get: 函数接口,返回类型为 c_int,参数为 c_void_p 和 c_int。
这些函数接口的具体功能需要根据实际的动态链接库 Octree_python_lib.so 来确定。
r_path = os.path.dirname(__file__) TabError: inconsistent use of tabs and spaces in indentation
这个错误是由于代码中的缩进混用了制表符和空格导致的。Python中要求缩进必须一致,要么使用制表符,要么使用空格。
你可以尝试将代码中的缩进全部改为统一的空格或者统一的制表符,确保每一行的缩进方式一致。
例如,将代码修改为使用四个空格作为缩进:
```python
def run_testcases(self):
pattern = '*.air'
r_path = os.path.dirname(__file__)
testcases_dir = os.path.join(r_path, 'testcase')
testcases = fnmatch.filter(os.listdir(testcases_dir), pattern)
for air_name in testcases:
print(air_name)
run_testcases()
```
或者改为使用制表符作为缩进:
```python
def run_testcases(self):
pattern = '*.air'
r_path = os.path.dirname(__file__)
testcases_dir = os.path.join(r_path, 'testcase')
testcases = fnmatch.filter(os.listdir(testcases_dir), pattern)
for air_name in testcases:
print(air_name)
run_testcases()
```
请注意,你需要确保整个文件中的缩进方式是一致的。