src/us/socialgoodworking/mocklocation/IO.java
public static String readFile(Context context, String directory, String fName) {
    	
    	BufferedReader in = null;
    	File dir = context.getDir(directory, Context.MODE_PRIVATE);
    	if ( dir == null) {
    		Logging.debug(TAG, "readFile:", "Context.getDir() failed");
    		return new String();
    	}
    	
    	File rf = new File(dir, fName);
    	if (!rf.exists()) {
    		Logging.debug(TAG, "readFile", rf.getAbsolutePath() + "/" + rf.getName() + " does NOT exist");
    		return new String();
    	}
  
    	StringBuilder sb;
    	
    	try {
    		InputStream inStream = new FileInputStream(rf);
      	
    		InputStreamReader inputreader = new InputStreamReader(inStream, "UTF-8");
    		in = new BufferedReader(inputreader);        	
      	
    		String line;
    		sb = new StringBuilder();

    		line = in.readLine();

    		while (line != null) {
    			sb.append(line);
    			line = in.readLine();
    		}
          
    		Logging.debug(TAG, "readFile - routeFile contents = ", sb.toString());

    		return sb.toString();
    	} 
  
    	catch (IOException e) {
    		Logging.debug(TAG, "readFile:", e.getMessage());
    	}

    	finally {
    		if (in != null) {
    			try {
    				in.close();
    			} 
    			catch (IOException e) {
    				Logging.debug(TAG, "readFile:", e.getMessage());
    			}
    		}
    	}
    	
        return new String();
    }
/**
     * 
     * @param context		Application context
     * @param directory		The name of the directory
     * @param fName			The name of the file
     * @return				The saved routes if they exist, or an empty string otherwise. 
     */
@param context           Application context
@param directory         The name of the directory
@param fName                     The name of the file
@return                          The saved routes if they exist, or an empty string otherwise.
@param context Application context @param directory The name of the directory @param fName The name of the file @return The saved routes if they exist or an empty string otherwise .
public static String readFile(Context context, String directory, String fName) {
    	BufferedReader in = null;
    	File dir = context.getDir(directory, Context.MODE_PRIVATE);
    	if ( dir == null) {
    		Logging.debug(TAG, "readFile:", "Context.getDir() failed");
    		return new String();
    	}
    	File rf = new File(dir, fName);
    	if (!rf.exists()) {
    		Logging.debug(TAG, "readFile", rf.getAbsolutePath() + "/" + rf.getName() + " does NOT exist");
    		return new String();
    	}
    	StringBuilder sb;
    	try {
    		InputStream inStream = new FileInputStream(rf);
    		InputStreamReader inputreader = new InputStreamReader(inStream, "UTF-8");
    		in = new BufferedReader(inputreader);        	
    		String line;
    		sb = new StringBuilder();
    		line = in.readLine();
    		while (line != null) {
    			sb.append(line);
    			line = in.readLine();
    		}
    		Logging.debug(TAG, "readFile - routeFile contents = ", sb.toString());
    		return sb.toString();
    	} 
    	catch (IOException e) {
    		Logging.debug(TAG, "readFile:", e.getMessage());
    	}
    	finally {
    		if (in != null) {
    			try {
    				in.close();
    			} 
    			catch (IOException e) {
    				Logging.debug(TAG, "readFile:", e.getMessage());
    			}
    		}
    	}
        return new String();
    }
public static String readFile ( Context context , String directory , String fName ) { BufferedReader in = null ; File dir = context . getDir ( directory , Context . MODE_PRIVATE ) ; if ( dir == null ) { Logging . debug ( TAG , "readFile:" , "Context.getDir() failed" ) ; return new String ( ) ; } File rf = new File ( dir , fName ) ; if ( ! rf . exists ( ) ) { Logging . debug ( TAG , "readFile" , rf . getAbsolutePath ( ) + "/" + rf . getName ( ) + " does NOT exist" ) ; return new String ( ) ; } StringBuilder sb ; try { InputStream inStream = new FileInputStream ( rf ) ; InputStreamReader inputreader = new InputStreamReader ( inStream , "UTF-8" ) ; in = new BufferedReader ( inputreader ) ; String line ; sb = new StringBuilder ( ) ; line = in . readLine ( ) ; while ( line != null ) { sb . append ( line ) ; line = in . readLine ( ) ; } Logging . debug ( TAG , "readFile - routeFile contents = " , sb . toString ( ) ) ; return sb . toString ( ) ; } catch ( IOException e ) { Logging . debug ( TAG , "readFile:" , e . getMessage ( ) ) ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { Logging . debug ( TAG , "readFile:" , e . getMessage ( ) ) ; } } } return new String ( ) ; }
@param context           Application context
 @param directory         The name of the directory
 @param fName                     The name of the file
 @return                          The saved routes if they exist, or an empty string otherwise.
@param context Application context @param directory The name of the directory @param fName The name of the file @return The saved routes if they exist or an empty string otherwise .