Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.io.BufferedWriter;
  2. import java.io.FileWriter;
  3. import java.io.IOException;
  4. import java.util.Random;
  5.  
  6. class Program4
  7. {
  8.     public static void main(String[] args)
  9.     {
  10.         String ch;
  11.         String Filename = "/home/lab/po2/9/Desktop";
  12.         Random rand = new Random();
  13.         String alphabet = "qwertyuiopasdfghjklzxcvbnm1234567890~!@#$%^&*()_+<>?:|{}";
  14.         for (int i=0; i<1000; i++)
  15.         {
  16.             BufferedWriter bw = null;
  17.             FileWriter fw = null;
  18.             try
  19.             {
  20.                 ch=String.valueOf(alphabet.charAt(rand.nextInt(alphabet.length())));
  21.                 fw = new FileWriter(Filename);
  22.                 bw = new BufferedWriter(fw);
  23.                 bw.write(ch);
  24.             }
  25.             catch (IOException e)
  26.             {
  27.                 System.out.println("Blad zapisu!");
  28.                 System.exit(0);
  29.             }
  30.         }
  31.         }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement