Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

30 September, 2013

JAVA : Convert InputStream to String

You can use the following snippet to convert InputStream to String
 
    private static String getStringFromInputStream(InputStream is) {
        BufferedReader br = null;
        StringBuilder sb = new StringBuilder();

        String line;
        try {
            br = new BufferedReader(new InputStreamReader(is));
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return sb.toString();
    }

Thanks

12 July, 2012

Search about Text in Schema

I will present today solution help us in searching about specific text in entire schema.

Suppose you want to search about 'MANAGER' string at entire tables in your schema.
You will do select statement against every table in your schema and you will will identify every column in table at select statement.

So I developed generic procedure has input search text and generate select statement against every table in schema and execute it and return the result in DBMS OUTPUT console.

The procedure return ROWD per every table has search text in any of its own columns and print it in DBMS OUTUT console in below format
<<ROWID>> IN TABLE <<TABLE_NAME>>

17 June, 2012

Strings in Java


I will present an article about different string Classes in java and comparison between them.
There are three String Classes in Java

1- java.lang.String
2- java.lang.StringBuilder
3- java.lang.StringBuffer

The most common class used in Java programming  is java.lang.String class.
To identify which Class we should use it, it depends on requirement, So let's first make comparison between them and at final get conclusion about guidance use.

13 April, 2012

Displaying Array as String in Java

Sometime in your code you want display array in string format.
Expected result is to display array collection as string (scalar data type) separated by comma.
Any array contains toString() method which returns informative only and doesn't contain any content of array.

For Example if I use toString() method with array
    public static void main(String[] args) {
        String[] str = new String[3];
        str[0] = "Mahmoud";
        str[1] = "Ahmed";
        str[2] = "El-Sayed";

        System.out.println(str.toString());
    } 


The output in console is
>>>>>>>>use toString() against array
[Ljava.lang.String;@9931f5


10 April, 2012

Sort String in PLSQL

I will develop PLSQL function which sorts string regarding ACII code of characters
This function uses a lot of intelligence to sort strings.

Idea of Sorting
I depend on create PLSQL table indexed by BINARY_INTEGER which its index mapped to ASCII code of every character in my string and I store in table number of occurrence per every character.

24 March, 2012

List Contents of Directory from Oracle SQL


One of my colleagues asked me how to list all content of directory from Oracle SQL query.
I think UTL_FILE built-in package allow this, but I discovered It doesn't support this.

So I decide to develop java class for listing contents of directory, then use it in Oracle Database.

I will list steps I will do briefly 
1-Create collection to store list of files in it.
2-Develop Java Class for List contents of Directory
3-Add Java Class to Database
4-Create PLSQL wrapper function to Java method
5-Grant Read on Directory to Java
6-Call PLSQL Function

08 July, 2011

How to make split string separated by specific character

SA,
Today I will present plsql function that do solution for splitting string separated by specific character.
for example If I have string 'year,month,day,hour,minute,second' its elements separated by comma and We want the output to be like the following
year
month
day
hour
minute
second

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...