Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Main {
- public static String[] gibeInfoString(Color[] kolory){
- String[] info= new String[kolory.length];
- for(int i=0; i<kolory.length; i++){
- info[i]= kolory[i].toString();
- }
- return info;
- }
- public static byte[][] gibeInfoBytes(Color[] kolory){
- byte[][] info= new byte[kolory.length][kolory[0].toString().length()];
- for(int i=0; i<kolory.length; i++){
- info[i]= kolory[i].toString().getBytes();
- }
- return info;
- }
- public static void main(String[] args) {
- Color kolor= new Color(225, 125, 25);
- kolor.toString();
- Color[] kolory= new Color[10000];
- for(int i=0; i<kolory.length; i++){
- int r=(int)(Math.random()*225),
- g= (int)(Math.random()*225),
- b= (int)(Math.random()*225);
- kolory[i]= new Color(r,g,b);
- }
- try {
- String[] info= gibeInfoString(kolory);
- BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\s18668\\IdeaProjects\\26\\pierwszy.txt"));
- for(int i= 0; i< info.length; i++){
- out.write(info[i]);
- out.newLine();
- }
- out.close();
- }catch(IOException ex){
- ;
- }
- try{
- byte[][] bytes= gibeInfoBytes(kolory);
- BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\s18668\\IdeaProjects\\26\\drugi.txt"));
- for(int i=0; i<bytes.length; i++){
- for(int j=0; j< bytes[i].length; j++){
- out.write(bytes[i][j]);
- }
- out.newLine();
- }
- }catch(IOException ex){
- ;
- }
- try{
- FileReader read= new FileReader("C:\\Users\\s18668\\IdeaProjects\\26\\pierwszy.txt");
- double start= System.currentTimeMillis();
- int czytnik;
- while((czytnik=read.read())!=-1){
- ;
- }
- double end = System.currentTimeMillis();
- System.out.println(end-start);
- }catch(FileNotFoundException ex){
- ;
- }catch(IOException ex){
- ;
- }
- try{
- FileReader read= new FileReader("C:\\Users\\s18668\\IdeaProjects\\26\\drugi.txt");
- double start= System.currentTimeMillis();
- int czytnik;
- while((czytnik=read.read())!=-1){
- ;
- }
- double end = System.currentTimeMillis();
- System.out.println(end-start);
- }catch(FileNotFoundException ex){
- ;
- }catch(IOException ex){
- ;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement