public void externalSortTextFile(String inputFileName, String outputFileName, boolean is_int)
	{
		String tfile = "temp-file-";
		ArrayList<String> buffer = new ArrayList<String>();
		
		try
		{
			File	   inputFile = new File(inputFileName);
			FileReader fr = new FileReader(inputFile.getAbsoluteFile());
			BufferedReader br = new BufferedReader(fr);
			boolean is_eof = false;
			int i, j;
			i = j = 0;
			
			// Iterate through the elements in the file
			while(true)
			{
				// Read MAX_ITEMS_IN_CHUNK-element chunk at a time from the file
				for (j = 0; j < MAX_ITEMS_IN_CHUNK; j++)
				{
					String t = br.readLine();
					if (t != null)
					{
						buffer.add(t);
					}
					else
					{
					 	is_eof = true;
					 	break;					 	
					}
				}
				// Sort MAX_ITEMS_IN_CHUNKM elements
				String ar_buffer[];
				if(is_int)
				{
					Integer in_buffer[] = buffer.toArray(new Integer[0]);
					Arrays.sort(in_buffer);
					
					int a_size = buffer.size();
					ar_buffer = new String[a_size];
					for(i = 0; i < a_size; i++)
					{
						ar_buffer[i] = in_buffer[i].toString();
					}
				}
				else
				{
					String str_buffer[] = buffer.toArray(new String[0]);
					Arrays.sort(str_buffer);
					ar_buffer = str_buffer;
				}								
								
				// Write the sorted data to temp file
				FileWriter fw = new FileWriter(inputFile.getParent() + tfile + Integer.toString(i) + ".tmp");
				BufferedWriter bw = new BufferedWriter(fw);
				for (int k = 0; k < j; k++)
				{
				 	bw.write(ar_buffer[k]);
				 	bw.newLine();
				}
				// Increase number of chunk files
				i++;
				
				// Close and clean resource
				bw.close();
				fw.close();
				buffer.clear();
				
				// If reached the EOF, break
				if(is_eof)
					break;
			}
			
			br.close();
			fr.close();
				
			// merge the sorted chunk files
			externalMergeTextFile(inputFile.getParent(), tfile + "*.tmp", outputFileName, is_int);
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
	}