내가 추가 할 때마다 경우없이 삭제됩니다하지 :파일은 그것이 사실 인 경우에도 if 문으로 삭제하지만, 문
if(lines[0].equalsIgnoreCase("owner: " + sender.getName()))
파일이 삭제되지 않습니다,하지만 아직이 :
System.out.println("Deleted message successfully!");
여전히 실행됩니다. 즉 if 문이 참임을 의미합니다.
위의 if 문을 삭제할 때마다 파일이 삭제됩니다. (안 최고)
String lines[], strLine;
int a = 0;
String fileLoc = currentDir + "//plugins//ExtendedSigns//" + c[1] + ".txt";
LineNumberReader lnr = new LineNumberReader(new FileReader(new File(fileLoc)));
FileInputStream in = new FileInputStream(fileLoc);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
lnr.skip(Long.MAX_VALUE);
lines = new String[1 + lnr.getLineNumber()];
while ((strLine = br.readLine()) != null)
{
lines[a] = strLine;
a++;
}
if(lines[0].equalsIgnoreCase("owner: " + sender.getName()))
{
File del = new File(currentDir + "//plugins//ExtendedSigns//" + c[1] + ".txt");
del.delete();
System.out.println("Deleted message successfully!");
}
else
{
System.out.println("Deleted message unsuccessfully! You do not own it!");
}
delete는 파일이 실제로 삭제되었는지 여부를 나타내는 부울을 반환합니다. 왜, 몰라요 - 당신이 당신이 그것을 실행할 때 당신이 생각하는 디렉토리에 있습니까? 권한이 있습니까? 여분의 슬래시는 무엇입니까? –
왜 경로에 두 개의'/'가 모두 필요합니까? –
if (lines [0] .equalsIgnoreCase ("owner :"+ sender.getName()))가없는 경우 manauly 파일 (오른쪽 클릭> 삭제됨)을 삭제할 수 있습니다. if 문을 사용하지 않고 삭제하기 때문에 디렉토리가 옳아야합니다. '강제로'삭제할 수있는 방법이 있습니까? – matt