Google+

Wednesday, September 14, 2011

How to Convert InputStream to String In Java

Here is the Simple method to convert InputStream Object to String Object.


Just Call this method and pass InputStream Object. it return the String






public static String convertStreamToString(InputStream is) throws Exception
{
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();
    String line = null;

    while ((line = reader.readLine()) != null) {
        sb.append(line);
    }

    is.close();

    return sb.toString();
}

Tuesday, September 13, 2011

How to get Multiple Select List-Box in PHP

Multiple ListBox in HTML will send the array of selected item. 
 
 
 
Sample PHP Code to access the Multiple Selected List-Box Values.
 
<html>
<head>
<title>List Box Form Data</title>
</head>
<body>
     <h3>List Box Form Data</h3>
     <p>Form data passed from the form</p>
    
    <?php
        echo "<p>select: " . $_POST['select']."</p>\n"; 
        echo "<p>listbox: " . $_POST['listbox'] . "</p>\n";
        $values = $_POST['listmultiple'];
        echo "<p>listmultiple: ";
        foreach ($values as $a){
            echo $a;
        }
        echo "</p>\n";
    ?>
</body>
</html>

Friday, September 9, 2011

How to find Android Unique Device ID or UDID - Part 1

Here is the Simple Statement to find Android Device ID which return a String.


String udid = Secure.getString(getContentResolver(), Secure.ANDROID_ID)




Please Note : 
ANDROID_ID is a 64-bit number (as a hex string) that is RANDOMLY GENERATED on the device's first boot and should remain constant for the lifetime of the device.(The value may change if a factory reset is performed on the device.)

Source : Android Documentation
Google+