Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.jdesktop.swingx.ux.*;
- import cn.vearn.checktreetable.*;
- import org.dom4j.*;
- import java.util.List;
- import javax.xml.bind.annotation.XmlElement;
- import javax.xml.bind.annotation.XmlRootElement;
- import java.io.*;
- import java.util.List;
- import java.util.Vector;
- public class Inputi {
- public static void InpStream() throws FileNotFoundException, IOException, DocumentException {
- try(FileInputStream inp = new FileInputStream("C:\\Users\\Sekvoya\\IdeaProjects\\LabSecSem\\src\\input.txt")) {
- byte[] buffer = new byte[inp.available()];
- inp.read(buffer, 0, inp.available());
- for(int i = 0; i < buffer.length; i++) {//
- System.out.print((char)buffer[i]); //
- } //
- String inpString = new String(buffer);
- Document document = DocumentHelper.parseText(inpString);
- Element root = document.getRootElement();
- List<Node> nodes = document.selectNodes("");
- for (Node node : nodes) {
- System.out.println(node.selectSingleNode("Name").getText() + '\n');
- }
- System.out.println('\n' + document.getRootElement().getName());//
- }
- catch (FileNotFoundException ex){
- System.out.println("File not exists!");
- }
- catch (IOException ex){ //надо посмотреть, что это за эксепшн
- System.out.println("Input exception!");
- }
- catch (DocumentException ex){
- System.out.println("Document exception!");//тоже хз
- }
- @XmlRootElement(name="Pet")
- class myPet {
- @XmlElement(name="Name")
- public String name;
- @XmlElement(name="Age")
- public int age;
- @XmlElement(required=false, name="NickName")
- public String nickName;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement