Groovy(Windows)のファイルを読むのに非常に不満な問題があります。私はかなりの時間をかけて根本原因を突き止めようとしました。しかし、私は2つの同一のファイル名に一致していないので、それを煮詰めているので、私は冗談です!ファイルが存在し、標準的な方法でパスを与えることができません。同じ文字列が一致しません - Groovy
ここではいくつかの診断コードと結果があります:
def rootPath = "x:/"
def filePath
files.each
{
filePath = rootPath + it
File xmlFile = new File(filePath)
println xmlFile.canRead() //returns : false
println xmlFile.exists() //returns : false
xmlFile = new File(new File(filePath).getParent() + "/" + new File(filePath).getName().toString())
println xmlFile.canRead() //returns : false
String fileName = new File(filePath).getName()
String parentDir = new File(filePath).getParent()
new File(parentDir).list().each
{
println "|" + it + "|" + fileName + "|"
//returns |PreUpload_140111-192158.xml|PreUpload_140111-192158.xml|
println it.toString().equals(fileName)
//returns false!!
println "Can Read : " + new File(parentDir + "/" + it.toString()).canRead()
//returns true
}
}
4行目で 'each'に' files'を使用しているのは何ですか? –
'ファイル'は以下のような部分パス文字列のリストです: 'Rel_2011.01/V112V80V90V100Mk8/2011.01.259/PC_12_V112_3MW_50HZ_Target_20110114-122312/PreUpload_140111-120351.xml' –