jboss의 conf 디렉토리 아래에있는 xml 파일에 쓰고 싶습니다.jboss 디렉토리에 파일을 작성하십시오.
나는 다음과 같이 엽니 다 :
public void initialiserXml() {
sxb = new SAXBuilder();
try {
String fileXml= System.getProperty("jboss.server.home.dir").concat("/").concat("/conf").concat("/exempleMessage.xml");
System.out.println("Fichier xml " +fileXml);
document = sxb.build(fileXml);
racine = document.getRootElement();
System.out.println("Fichier Xml trouvé");
} catch (FileNotFoundException e) {
System.err.println("Aucun fichier XML trouvé");
} catch (JDOMException e) {
System.err.println("Fichier XML mal construit");
} catch (IOException e) {
System.err.println("Impossible d ' ouvrir le fichier XML");
}
}
및 수정 후 나는이
public void enregistreFichier()
{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
try {
sortie.output(document, new FileOutputStream(fileXml));
} catch (FileNotFoundException e) {
System.err.println("Fichier XML source non trouvé");
} catch (IOException e) {
System.err.println("Impossible d ' ecrire dans le fichier XML");
}
}
이 내 테스트 환경에서 작동
하지만 같은 변경 내용을 기록 나는 (프로덕션 환경에서이를 테스트 할 때 리눅스 서버), 더 이상 작동하지 않습니다 내가 sortie.output (document, new FileOutputStream (fileXml));에 전달하면; (FileNotFoundException이)
내가 SAXBuilder도 그것을 열 때 내 파일이 발견되어, t 이해 돈하지만 난에 쓸 때, 나는 FileNotFoundException이
어떻게 문제를 해결하기를 바랍니다? 당신이 필요한 모든 허가의 파일에없는 경우
당신에게
또한 Linux에서 파일을 만들고 싶다면 (그리고 파일을 쓸 때 그 새로운 파일)'conf' 디렉토리에 대한 쓰기 권한이 필요합니다. –
고마워요! 사실 그것은 허가의 문제였습니다. chmod와 chown 명령으로 파일과 conf 디렉터리에 대한 액세스 권한을 부여했으며 이제는 완벽하게 작동합니다! 대단히 감사합니다. – user799698