[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.2

Java - File Location Configuration on Unix Box

Asked by Pungwick in Java Editors & IDEs

Tags: java, file, unix, location

Dear Experts,

I have the below Java Code and it seems to work fine when the specified path exists on my machine however when I deploy the code to a UNIX Box it doesnt work.

What I want to do is configure the code so that when I deploy this code onto a UNIX box I can specific a file as I have done on a normal pc in this code

package com.test.uk.eve;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;

// Referenced classes of package com.test.uk.eve:
//            ResultItem

      
    implements Serializable
{

    private static HashMap FILE_HASH_MAP = new HashMap();
    private static String fileName = "C:\\Factory\\Projects\\Build\\file.txt";

    public Utilities()
    {
    }

    public ResultItem getResultem(String theAction, String msisdn, String erId)
    {
        String key = theAction + "-" + msisdn + "-" + erId;
        String value = getValueGivenKey(key);
        ResultItem resultItem = new ResultItem();
        String strValueArray[] = parseValue(value);
        if(strValueArray == null)
        {
            return null;
        } else
        {
            String responseCode = strValueArray[0];
            String responseText = strValueArray[1];
            resultItem.msisdn = msisdn;
            resultItem.responseCode = responseCode;
            resultItem.responseText = responseText;
            return resultItem;
        }
    }

    public String[] populateStrArrayWithParameters(String key)
    {
        String strArray[] = new String[3];
        String deLimiter = "-";
        if(key == null)
        {
            return strArray;
        }
        int index = key.indexOf(deLimiter);
        for(int counter = 0; index != -1 && counter <= 1 && !key.equals(""); counter++)
        {
            strArray[counter] = key.substring(0, index);
            if(index + 1 <= key.length())
            {
                key = key.substring(index + 1, key.length());
            }
            index = key.indexOf(deLimiter);
        }

        strArray[2] = key;
        return strArray;
    }

    public String[] parseValue(String value)
    {
        String strArray[] = new String[2];
        String deLimiter = "-";
        if(value == null)
        {
            return strArray;
        }
        int index = value.indexOf(deLimiter);
        if(index != -1)
        {
            strArray[0] = value.substring(0, index);
        } else
        {
            strArray[0] = value;
            strArray[1] = null;
            return strArray;
        }
        if(index + 1 <= value.length())
        {
            strArray[1] = value.substring(index + 1, value.length());
        }
        return strArray;
    }

    public static String getValueGivenKey(String key)
    {
        if(key == null)
        {
            return null;
        } else
        {
            return (String)FILE_HASH_MAP.get(key);
        }
    }

    public static ArrayList readFile()
        throws Exception
    {
        File file = new File(fileName);
        FileReader fileReader = new FileReader(file);
        BufferedReader br = new BufferedReader(fileReader);
        ArrayList list = new ArrayList();
        for(String strLine = br.readLine(); strLine != null; strLine = br.readLine())
        {
            list.add(strLine);
        }

        br.close();
        fileReader.close();
        return list;
    }

    public static HashMap popualateHashMap()
        throws Exception
    {
        ArrayList list = readFile();
        if(list != null)
        {
            String deLimiter = "=";
            for(int i = 0; i < list.size(); i++)
            {
                String strEachLine = (String)list.get(i);
                String key = "";
                String value = "";
                if(strEachLine != null)
                {
                    int index = strEachLine.indexOf(deLimiter);
                    if(index != -1)
                    {
                        key = strEachLine.substring(0, index);
                        if(index + 1 <= strEachLine.length())
                        {
                            value = strEachLine.substring(index + 1, strEachLine.length());
                        }
                    } else
                    {
                        key = strEachLine;
                        value = null;
                    }
                    FILE_HASH_MAP.put(key, value);
                }
            }

        }
        return FILE_HASH_MAP;
    }

    static
    {
        try
        {
            popualateHashMap();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}

I hope someone can help

Regards
Pungwick
[+][-]06/04/07 11:10 AM, ID: 19210654Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Java Editors & IDEs
Tags: java, file, unix, location
Sign Up Now!
Solution Provided By: marklorenz
Participating Experts: 1
Solution Grade: B
 
[+][-]06/04/07 07:42 AM, ID: 19208884Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/07 08:19 AM, ID: 19209221Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/07 08:55 AM, ID: 19209567Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/07 09:16 AM, ID: 19209718Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/07 10:08 AM, ID: 19210170Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/07 10:24 AM, ID: 19210299Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/07 10:38 AM, ID: 19210395Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/07 10:51 AM, ID: 19210509Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/08/07 12:33 PM, ID: 19441015Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92