Monthly Archives: November 2009

Reading data from HttpURLConnection using Input Stream

When you are developoing applications (desktop or mobile) you often have to deal with web based services that you need to interact over HTTP(s). You would use “HttpURLConnection” class to connect to a remote web service and invoke calls using the “URL” aggreed upon.

example :

URL url = new URL(“”);
HttpURLConnection request = (HttpURLConnection) url.openConnection();

Once you havre the HttpURLConnection object, you can invoke “getInputStream()” method to access the response returned by the remote web application/URL.

example :

InputStream in = (InputStream) request.getInputStream();

In order to read the data in the InputStream object returned, you can use the following code.

example :

final char[] buffer = new char[0x10000];
StringBuilder out = new StringBuilder();
Reader r = new InputStreamReader(in, “UTF-8”);
int read;
do {
read =, 0, buffer.length);
if (read>0) {
out.append(buffer, 0, read);
while (read>=0);



Filed under Java, web, webservice

JavaScript : cool tips and tricks

Agreed JavaScript has nothing to do with Java, except for the sufix, I know JavaScript is not a full fledged programming language and many serious programmers consider it as a toy for teenagers, but it does pull up some powerfull yet cool stuffs for the web browser/UI. If you can take advantage of it, you can present your data in a better and flashyer way and win hearts, remember however complex your code might be, in the software world appearence does matter!.

some cool tricks .. most of it might be lame for javascript pros, but i want to put them together here for my reference…

Quick & Simple Auto Redirection

<script type="text/javascript">
window.location = ""

Simple Page with java Script for a Tabbed Page : – Example – summary.html

JS example of creating a Dynamic Tabbed Html page – This has the feature to dynamically load the tabs ( or the html files associated with the tabs ) instead of loading all data at once.

Drop Down to display stuff in the same page : – – Example – index.html

Collapsing Table using Javascript/DOM/CSS : – Example –

Leave a comment

Filed under javascript

ORACLE : Table Space Tricks!

tablespace First a brief introduction :

A tablespace is a logical storage unit within an Oracle database. It is logical because a tablespace is not visible in the file system of the machine on which the database resides. A tablespace, in turn, consists of at least one datafile which, in turn, are physically located in the file system of the server. Btw, a datafile belongs to exactly one tablespace.
Each table, index and so on that is stored in an Oracle database belongs to a tablespace. The tablespace builds the bridge between the Oracle database and the filesystem in which the table’s or index’ data is stored.
Lets get a bit Techincal – What is a DB_File :  DB_FILE is the physical file that is created to store the data in Oracle.  The db_files parameter is a “soft limit ” parameter that controls the maximum number of physical OS files that can map to an Oracle instance. Historically (before Oracle8i) you need to be careful not to set db_files too high, else you would have DBWR (database writer) issues. The maxdatafiles parameter is a different “hard limit” parameter.  When you issue a “create database” command, the value you specify for maxdatafiles is stored in your Oracle control files.  The default value of 32 is usually sufficient, but after Oracle8i there is no downside to using a larger value.
Issues – How to incerease table space when you run out :
1. Check for current db_file size –
Show parameter db_files;

NAME                                 TYPE        VALUE
———————————— ———– ——————————
db_files                             integer     100

2. Check if you have spfile by using the SQL command – show parameter spfile;
if you dont have spfile create one using the SQL command – create spfile from pfile;
3. Shutdown immidate; and startup mount;
4. alter system set db_files=750 scope=spfile; ( to incerease the db_file size )
5. Shutdown immidate; and startup mount;

Leave a comment

Filed under ORACLE

Enum : a quick example

Enum was added in jdk 1.5. There are some corners where you can find the use of “public static final int vars” .  A quick example for the time starved. This lets you use the Enum as a type or get the numerical value out of it if needed, example below :

enum Ids {

  private int value;    

  private Ids(int value) {
    this.value = value;

  public int getValue() {
    return value;

Usage : 

Ids i = Ids.OPEN;
int i = Ids.OPEN.getValue();

// JDK makes it easy for Enum to be used as part of a switch statement
    case Ids.OPEN : //code for this section
    case Ids.CLOSE : // code for this section

Leave a comment

Filed under Java