Bonjour voici ce code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;

public class SAXParserCheck{

  public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter XML file name:");
    String xmlFile = bf.readLine();
    SAXParserCheck par = new SAXParserCheck(xmlFile);
  }
  
  public SAXParserCheck(String str){
    try{
      File file = new File(str);
      if (file.exists()){
        XMLReader reader = XMLReaderFactory.createXMLReader();
        reader.parse(str);
        System.out.println(str + " is well-formed!");
      }
      else{
        System.out.println("File not found: " + str);
      }
    }
    catch (SAXException sax){
      System.out.println(str + " isn't well-formed");
    }
    catch (IOException io){
      System.out.println(io.getMessage());
    }
  }
}
ma question est: Comment remplacer System.out.print("Enter XML file name:") dans ce code afin de lire un fichier XML avec SAX à partir d'un emplacement non fixé c'est à dire à partir du C:,D: bien un flache disque, exactement comment réaliser le parcour pour lire le fichier XML.
Merci d'avance et bonne journée.