Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class Main {
  4. public static String[] gibeInfoString(Color[] kolory){
  5. String[] info= new String[kolory.length];
  6. for(int i=0; i<kolory.length; i++){
  7. info[i]= kolory[i].toString();
  8. }
  9. return info;
  10. }
  11.  
  12. public static byte[][] gibeInfoBytes(Color[] kolory){
  13. byte[][] info= new byte[kolory.length][kolory[0].toString().length()];
  14. for(int i=0; i<kolory.length; i++){
  15. info[i]= kolory[i].toString().getBytes();
  16. }
  17. return info;
  18. }
  19. public static void main(String[] args) {
  20. Color kolor= new Color(225, 125, 25);
  21. kolor.toString();
  22. Color[] kolory= new Color[10000];
  23. for(int i=0; i<kolory.length; i++){
  24. int r=(int)(Math.random()*225),
  25. g= (int)(Math.random()*225),
  26. b= (int)(Math.random()*225);
  27. kolory[i]= new Color(r,g,b);
  28. }
  29.  
  30. try {
  31. String[] info= gibeInfoString(kolory);
  32. BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\s18668\\IdeaProjects\\26\\pierwszy.txt"));
  33. for(int i= 0; i< info.length; i++){
  34. out.write(info[i]);
  35. out.newLine();
  36. }
  37. out.close();
  38. }catch(IOException ex){
  39. ;
  40. }
  41. try{
  42. byte[][] bytes= gibeInfoBytes(kolory);
  43. BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\s18668\\IdeaProjects\\26\\drugi.txt"));
  44. for(int i=0; i<bytes.length; i++){
  45. for(int j=0; j< bytes[i].length; j++){
  46. out.write(bytes[i][j]);
  47. }
  48. out.newLine();
  49. }
  50. }catch(IOException ex){
  51. ;
  52. }
  53. try{
  54. FileReader read= new FileReader("C:\\Users\\s18668\\IdeaProjects\\26\\pierwszy.txt");
  55. double start= System.currentTimeMillis();
  56. int czytnik;
  57. while((czytnik=read.read())!=-1){
  58. ;
  59. }
  60. double end = System.currentTimeMillis();
  61. System.out.println(end-start);
  62. }catch(FileNotFoundException ex){
  63. ;
  64. }catch(IOException ex){
  65. ;
  66. }
  67. try{
  68. FileReader read= new FileReader("C:\\Users\\s18668\\IdeaProjects\\26\\drugi.txt");
  69. double start= System.currentTimeMillis();
  70. int czytnik;
  71. while((czytnik=read.read())!=-1){
  72. ;
  73. }
  74. double end = System.currentTimeMillis();
  75. System.out.println(end-start);
  76. }catch(FileNotFoundException ex){
  77. ;
  78. }catch(IOException ex){
  79. ;
  80. }
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement