Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing a system that ask the user to enter text in textarea(plaintext) then it encrypt it using key entered by user in textbox(key). after that it calculate the user input text size, this is how the code is. but in the running time it only show the "yottabytes" in the textarea(size)

Java
byte[] plain = plaintext.getText().getBytes();
byte[] K = key.getText().getBytes();

byte[] encrypted = encrypt(plain, K);
    String a = bytesToHex(encrypted);
    encryptedtext.setText(a);


    String desc[] = new String[]{"bytes ", " kilobytes", " megabytes", " gigabytes", "terabytes", "petabytes", "exabytes", "zettabytes", "yottabytes"};
    String s = plaintext.getText();
    double len = s.length();

    for (String d : desc) {
        size.setText(d + " : " + len);
        len /= 1024;

    }


What I have tried:

size.append("\n");

but didn't work
Posted
Updated 2-Apr-18 21:43pm

1 solution

Maybe you should use
size.append(d + " : " + len+"\n");
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900