Advertisement
gkalmoukis

Java-erotima-2

Jan 23rd, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.io.FileWriter;  
  2. import java.io.IOException;  
  3.  
  4. public class erotima2 {
  5.   //main sinartisi , to programma arxizei apo edo
  6.   public static void main(String[] args) {
  7.     // dokimazei an borei
  8.     try {
  9.       //dimiourgei to arxeio an den yparxei
  10.       FileWriter myWriter = new FileWriter("file.txt");
  11.       // epanaliptika 10 000 fores
  12.       for (int i = 0; i < 10000; i++) {
  13.         //grafei sto arxeio to i (pou einai o trexon arithmos tis epanalipsis)
  14.         //kai ton xaraktira diafigis \n poy paei ton kersora stin epomeni grammi toy arxeio
  15.         myWriter.write(i+"\n");
  16.     }
  17.     //kleinei to arxeio , kalo gia tin mnimi
  18.       myWriter.close();
  19.     //an den borei emfanizei minima lathous  
  20.     } catch (IOException e) {
  21.       System.out.println("Δεν μπορώ :( ");
  22.       e.printStackTrace();
  23.     }
  24.   }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement