我想从带有DirectoryChooser的目录中获取路径。我的代码看起来像这样:
DirectoryChooser dc = new DirectoryChooser();
dc.showDialog(stage);
File f = dc.getInitialDirectory();
String s = f.getAbsolutePath();
System.out.println(s);
但那不起作用,有人可以帮助我吗?方法getInitialDirectory()始终为null
答案 0 :(得分:8)
看起来应该是这样的:
def heapify(arr, n, i):
count = 0
largest = i
l = 2 * i + 1
r = 2 * i + 2
if l < n and arr[i] < arr[l]:
largest = l
if r < n and arr[largest] < arr[r]:
largest = r
if largest != i:
count += 1
arr[i],arr[largest] = arr[largest],arr[i]
count += heapify(arr, n, largest)
return count
def heapSort(arr):
n = len(arr)
count = 0
for i in range(n, -1, -1):
heapify(arr, n, i)
count += heapify(arr, i, 0)
for i in range(n-1, 0, -1):
arr[i], arr[0] = arr[0], arr[i]
count += heapify(arr, i, 0)
return count