Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import org.jdesktop.swingx.ux.*;
  2. import cn.vearn.checktreetable.*;
  3. import org.dom4j.*;
  4. import java.util.List;
  5.  
  6. import javax.xml.bind.annotation.XmlElement;
  7. import javax.xml.bind.annotation.XmlRootElement;
  8. import java.io.*;
  9. import java.util.List;
  10. import java.util.Vector;
  11.  
  12. public class Inputi {
  13. public static void InpStream() throws FileNotFoundException, IOException, DocumentException {
  14. try(FileInputStream inp = new FileInputStream("C:\\Users\\Sekvoya\\IdeaProjects\\LabSecSem\\src\\input.txt")) {
  15. byte[] buffer = new byte[inp.available()];
  16. inp.read(buffer, 0, inp.available());
  17.  
  18. for(int i = 0; i < buffer.length; i++) {//
  19. System.out.print((char)buffer[i]); //
  20. } //
  21.  
  22. String inpString = new String(buffer);
  23. Document document = DocumentHelper.parseText(inpString);
  24. Element root = document.getRootElement();
  25. List<Node> nodes = document.selectNodes("");
  26.  
  27. for (Node node : nodes) {
  28. System.out.println(node.selectSingleNode("Name").getText() + '\n');
  29. }
  30.  
  31. System.out.println('\n' + document.getRootElement().getName());//
  32.  
  33. }
  34. catch (FileNotFoundException ex){
  35. System.out.println("File not exists!");
  36. }
  37. catch (IOException ex){ //надо посмотреть, что это за эксепшн
  38. System.out.println("Input exception!");
  39. }
  40. catch (DocumentException ex){
  41. System.out.println("Document exception!");//тоже хз
  42. }
  43.  
  44.  
  45. @XmlRootElement(name="Pet")
  46. class myPet {
  47. @XmlElement(name="Name")
  48. public String name;
  49.  
  50. @XmlElement(name="Age")
  51. public int age;
  52.  
  53. @XmlElement(required=false, name="NickName")
  54. public String nickName;
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement