Java method to get all the XML documents under the current path

  • 2020-04-01 03:18:04
  • OfStack

 
import java.io.File; 

public class ShowAllXML { 
public static void main(String[] args) { 
File file = new File("").getAbsoluteFile(); 
String[] dir; 
dir = file.list(); 
for (int i = 0; i < file.list().length; i++) { 
if (dir[i].length() > 4) { 
if (dir[i].endsWith(".xml")) { 
print(dir[i]); 
} 
} 
} 

} 

private static void print(String string) { 
System.out.println(string); 
} 
} 

* for beginners, please point out any problems you find.

Related articles: