public String selectFile(int mode) {
			
		String returnVal = null;
		int ret = 0;
		
		final JFileChooser fc = new JFileChooser();
		
		JFrame frame = new JFrame("FileChooser");
		
		//show open or save dialog
		fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
		
		if(mode == MODE_OPEN) 
		{
			ret = fc.showOpenDialog(frame.getJMenuBar());
		}
		else if (mode == MODE_SAVE) 
		{
			ret = fc.showSaveDialog(frame.getJMenuBar());
		}
		
		if (ret == JFileChooser.CANCEL_OPTION) 
		{
			returnVal = null;
		}
		else if(ret == JFileChooser.APPROVE_OPTION) 
		{
			File file=fc.getSelectedFile();
			
			returnVal=file.getPath();
		}
		
		return returnVal;
	}