Java split giving opposite order of arabic characters

Posted by MuhammadA on Stack Overflow See other posts from Stack Overflow or by MuhammadA
Published on 2013-11-10T00:34:28Z Indexed on 2013/11/10 15:54 UTC
Read the original article Hit count: 321

Filed under:
|
|
|
|

I am splitting the following string using \\| in java (android) using the IntelliJ 12 IDE.

enter image description here

Everything is fine except the last part, somehow the split picks them up in the opposite order :

enter image description here

As you can see the real positioning 34,35,36 is correct and according to the string, but when it gets picked out into split part no 5 its in the wrong order, 36,35,34 ...

Any way I can get them to be in the right order?

My Code:

public ArrayList<Book> getBooksFromDatFile(Context context, String fileName)
{
    ArrayList<Book> books = new ArrayList<Book>();

    try
    {
        // load csv from assets
        InputStream is = context.getAssets().open(fileName);

        try
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));

            String line;
            while ((line = reader.readLine()) != null)
            {
                String[] RowData = line.split("\\|");
                books.add(new Book(RowData[0], RowData[1], RowData[2], RowData[3], RowData[4], RowData[5]));
            }
        }
        catch (IOException ex)
        {
            Log.e(TAG, "Error parsing csv file!");
        }
        finally
        {
            try
            {
                is.close();
            }
            catch (IOException e)
            {
                Log.e(TAG, "Error closing input stream!");
            }
        }
    }
    catch (IOException ex)
    {
        Log.e(TAG, "Error reading .dat file from assets!");
    }

    return books;
}

© Stack Overflow or respective owner

Related posts about java

Related posts about android