System.out.println("READ");
String currentWorldName = "RANDOM";
String propertiesFileDirectory = propertiesFolder + currentWorldName + "/props.properties";
String entitiesFolderDirectory = propertiesFolder + currentWorldName + "/Entities";
try
{
properties.load(new FileInputStream(propertiesFileDirectory));
}
catch (FileNotFoundException e)
{
//Since it doesn't exist either it was deleted by the user or hasn't been created yet.
createNewPropertiesFile();
}
catch (IOException e)
{
outputToLog("IOException when loading properties file for the world: '" + currentWorldName + "'.\n" + e.getStackTrace().toString());
}
//getting values from properties
//Now to read each properties file in Entities
File entitiesFolder = new File(entitiesFolderDirectory);
try
{
List<String> entitiesDirectoryContents = Arrays.asList(entitiesFolder.list());
//Read each file in the entities directory and load it into memory.
for (String entityPropertiesFileName : entitiesDirectoryContents)
{
if (propertiesBelongsToEntityCH(entityPropertiesFileName))
{
//Get properties one way
}
else //The properties file we're working does not belong to CH.
{
//Get properties from the same file a different way
}
}
//This should never be hit since we have the file to read.
catch (FileNotFoundException e)
{
outputToLog("FileNotFoundException when loading entity properties file." + e.getMessage().toString());
}
//I don't know when/if this would be hit. It hasn't happened.
catch (IOException e)
{
outputToLog("IOException when loading entity properties file." + e.getMessage().toString());
}
catch (NullPointerException e)
{
entitiesFolder.mkdirs();
}
이 작업이 진행 중입니다. 이제 막 시작되었습니다. Java는 "entitiesFolder"디렉토리가 존재하지 않는다고 주장합니다. entitiesFolder.exists()로 확인합니다. 내 프로그램을 실행하는 동안 분명히 일어날 수 있기 때문에 당신이 볼 수있는대로 일어나는 때를위한 해결책이 있습니다. 아직도 폴더가 존재하지 않는다고 주장합니다.Java가 디렉토리에 파일을 가져 오지 않았습니다.
"entitiesFolderDirectory"를 콘솔에 인쇄하기 때문에 올바른 디렉토리라는 것이 절대적으로 긍정적입니다. 맞습니다. mkdirs()가 실행될 때 그 폴더 안의 파일들을 볼 수도 있습니다.
자바 버그? 이것은 내 프로그램을 완전히 망가 뜨 렸습니다.
유 창에 맞아 테스트 디렉토리에있는 파일을 나열합니다 다른 존재하지 않는 경우
이 C 드라이브의 디렉토리 테스트를 만들 것인가? – Eugene
예. Windows 7 x64 – WildBamaBoy
에 액세스하려고 시도하는 실제 경로가 없으면 '얼마나 긴 문자열입니까?' – mcfinnigan