Objective C: UITextField controlling background image/color

If you set
UITextField *tf = [[UITextField alloc] init];
tf.borderStyle = UITextBorderStyleRoundedRect;
you can't control background of text field. To controlling background you need
#import "QuartzCore/QuartzCore.h"
...

UITextField *tf = [[UITextField alloc] init];
tf.borderStyle = UITextBorderStyleDefault;
tf.background = [UIImage imageNamed:@"bg_000000_20.png"];
tf.layer.cornerRadius = 5.0;
tf.layer.masksToBounds = YES;

// for vertical align
tf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

// for border
tf.layer.borderWidth = 1.0;
tf.layer.borderColor = [[UIColor darkGrayColor] CGColor];

// for left padding
tf.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
tf.leftViewMode = UITextFieldViewModeAlways;

Java: Read key from Windows Registry.

After create new windows registry in cmd by:
reg add HKLM\SOFTWARE\Policies\MyApplication\AES /v SecurityKey /d 12345678901234567890123456789012
need read it from java
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

public class WindowsReqistry {

    /**
     * 
     * @param location path in the registry
     * @param key registry key
     * @return registry value or null if not found
     */
    public static final String readRegistry(String location, String key){
        try {
            // Run reg query, then read output with StreamReader (internal class)
            Process process = Runtime.getRuntime().exec("reg query " + 
                    '"'+ location + "\" /v " + key);

            StreamReader reader = new StreamReader(process.getInputStream());
            reader.start();
            process.waitFor();
            reader.join();

            // Parse out the value
            String[] parsed = reader.getResult().split("\\s+");
            if (parsed.length > 1) {
                return parsed[parsed.length-1];
            }
        } catch (Exception e) {}

        return null;
    }

    static class StreamReader extends Thread {
        private InputStream is;
        private StringWriter sw= new StringWriter();

        public StreamReader(InputStream is) {
            this.is = is;
        }

        public void run() {
            try {
                int c;
                while ((c = is.read()) != -1)
                    sw.write(c);
            } catch (IOException e) { 
            }
        }

        public String getResult() {
            return sw.toString();
        }
    }
    public static void main(String[] args) {

        // Sample usage
        String value = WindowsReqistry.readRegistry("HKLM\\SOFTWARE\\Policies\\MyApplication\\AES", "SecurityKey");
        System.out.println(value);
    }
}