Reading and returning multiple bin files
<pre><code>    private static int count = 0;

    public static String[] play()throws Exception{
        File file=new File("E:/proj/"+count+".bin");
        FileInputStream fin=new FileInputStream("E:/proj/"+count+".bin");

        //reading the byte content of the bin files
        byte fileContent[] = new byte[(int)file.length()];
        fin.read(fileContent);

        //storing the deserialized object that is returned to an object.
        Object obj=serializer.toObject(fileContent);

        //converting the obtained object to string 
        String word=obj.toString();
        String[] args=new String[]{word};
        count++;
        return args ;          
    } 
</code></pre>

<p>This snippet was actually supposed to read all the bin files present in that specified path and eventually convert it to string and store all the <code>byte[]</code> converted to strings as different string elements in a <code>string[]</code>  return the <code>string[]</code>. Though it reads all the bin files owing to the counter, somehow, it returns only string of the 1st binary file it reads. </p>

<p>Even this modified version dosent seem to work. I guess it reads all the bin files, but returns only the string of the last bin file read. What i was trying out for was, to store all the string elements to the <code>string[]</code> and return the <code>string[]</code> to another calling function.</p>

<pre><code>public static String[] play(){
    int i = 1;
    String[] args=null;;
    String result = null;
    while (true) {
        try {
            result += processFile(i++);
            args=new String[]{result}; 
        } 
            catch (Exception e) {
            System.out.println("No more files");
            break;
        }
    }  
    return args;
}       

private static String processFile(int fileNumber) throws Exception {
    File file=new File("E:/proj/"+fileNumber+".bin");
    FileInputStream fin=new FileInputStream("E:/proj/"+fileNumber+".bin");

    //reading the byte content of the bin files
    byte fileContent[] = new byte[(int)file.length()];
    fin.read(fileContent);

    //storing the deserialized object that is returned, to an object.
    Object obj=serializer.toObject(fileContent);

    //converting the obtained object to string 
    String word=obj.toString();
    return word;
}
</code></pre>
