“Leser” Code-Antworten

Leser

   public static void main(String[] args) throws IOException {

    Stack stack = new Stack(); 
    Queues queue = new Queues();

    File stackfile = new File("stack.txt"); 


    if (!stackfile.exists()) { 
        stackfile.createNewFile(); 
    } else {
        System.out.println("File is done"); 
    }
    FileReader r= new FileReader(stackfile);
    BufferedReader reader = new BufferedReader(r); 

    String line = null; 
    Data data= new Data(); // this class have String name, surname and string number

    int i=1;
    while ((line=reader.readLine())!=null) { 

        { if(line.trim().equals("#")){
            stack.Push(data);
            data=new Data();
            i=1;
        }
        else{
            if(i==1){
                data.setNo(line);
            }
            else if(i==2){
                data.setName(line);

            }
            else if(i==3){
                data.setSurName(line);
            }
            i++;

            }
        }





    }
    stack.Push(data);
    reader.close();

    File queuefile = new File("queue.txt"); 

    if (!queuefile.exists()) { 
        queuefile.createNewFile(); 
    } else {
        System.out.println("File is done");
    }

    BufferedReader read = null; 
    read = new BufferedReader(new FileReader(queuefile));
    String lines = read.readLine();


    while (lines != null) { 
        System.out.println("Read from queue: " + lines);


         { if(lines.trim().equals("#")){
            queue.insert(data);
            data=new Data();
            i=1;
        }
        else{
            if(i==1){
                data.setNo(line);
            }
            else if(i==2){
                data.setName(line);

            }
            else if(i==3){
                data.setSurName(line);
            }
            i++;

            }
        }


    }
    queue.insert(data);
    read.close();

   }
  }
Xerothermic Xenomorph

Bildschirmlesertext

/* Text meant only for screen readers. */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}
Brave Developer

Ähnliche Antworten wie “Leser”

Fragen ähnlich wie “Leser”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen