大写.xmlXML读取器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大写.xmlXML读取器相关的知识,希望对你有一定的参考价值。

Stores country name code and capital in an array and returns it. (not completed)
  1. package xmlReader;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FilePermission;
  7. import java.io.FileReader;
  8. import java.io.IOException;
  9. import java.nio.file.Files;
  10. import java.util.StringTokenizer;
  11.  
  12. public class CapitalsReader {
  13.  
  14. String fileName;
  15.  
  16. String [][] capitals = new String[249][3];
  17.  
  18. int quoteCount = 0;
  19.  
  20. public CapitalsReader()
  21. {
  22.  
  23.  
  24. }
  25.  
  26. public static void main(String[] args) {
  27.  
  28. CapitalsReader capitals_reader = new CapitalsReader();
  29.  
  30. capitals_reader.Read();
  31.  
  32. System.out.println("End");
  33.  
  34. }
  35.  
  36. public String [][] Read()
  37. {
  38.  
  39. try {
  40.  
  41. String fileName ="C:/Users/User/workspace/se5/src/xmlReader/Capitals.xml";
  42. BufferedReader br = new BufferedReader( new FileReader(fileName));
  43.  
  44. int lineNumber = 0; int tokenNumber = 0;
  45.  
  46. while( (fileName = br.readLine()) != null)
  47. {
  48.  
  49. lineNumber++;
  50.  
  51. tokenNumber = 0;
  52.  
  53. // skip second line
  54.  
  55. if(lineNumber!=1)
  56.  
  57. {
  58.  
  59. StringTokenizer stringTokenizer = new StringTokenizer(fileName);
  60.  
  61. while (stringTokenizer.hasMoreTokens())
  62.  
  63. {
  64.  
  65. String token = stringTokenizer.nextToken();
  66.  
  67. if(tokenNumber == 0 && lineNumber ==4)
  68.  
  69. {
  70. System.out.println("tokenNumber: "+tokenNumber);
  71. System.out.println("token: "+token);
  72. }
  73.  
  74.  
  75.  
  76. tokenNumber++;
  77.  
  78. /*
  79. TO DO code to check for the tokens you want so you
  80. can insert the correct elements into the String [][]
  81. capitals. Use the fact that the country name begins
  82. after the first " and ends at the second, the country
  83. code runs from the fifth " to the 6th and the capital
  84. from the 15th " to the 16th. Once you've processed the
  85. capital, break ou of the while loop.
  86. */
  87.  
  88. //if()
  89.  
  90. break;
  91. }
  92.  
  93. lineNumber++;
  94.  
  95. }
  96.  
  97. }
  98.  
  99. } catch (FileNotFoundException e) {
  100. // TODO Auto-generated catch block
  101. e.printStackTrace();
  102. } catch (IOException e) {
  103. // TODO Auto-generated catch block
  104. e.printStackTrace();
  105. }
  106.  
  107. finally
  108. {
  109. // do whatever you want here i.e. print something like "finished"
  110. }
  111. return capitals;
  112.  
  113.  
  114. }
  115.  
  116. }

以上是关于大写.xmlXML读取器的主要内容,如果未能解决你的问题,请参考以下文章

solr分布式索引实战分片配置读取:工具类configUtil.java,读取配置代码片段,配置实例

在 SQL 中读取 XML BOOLEAN 值

GLSL:无法从 FBO 读取纹理并使用片段着色器渲染到另一个 FBO

OpenGL、GLSL 片段着色器无法读取 Sampler2D 纹理

读取只包含标签的xml

为什么对象页面部分标题进入大写字母以及如何禁用它