Hello ..
I am trying to open an encrypted file, and then pass it to my decryption method to decrypt it and display the text on the screen .. I'm getting a null!

This is my decrypt code:

public String decrypt(String encrypted)
		StringBuilder decryption = new StringBuilder();

		for(int i=0; i< encrypted.length(); i++)
			int pos=0;
			int index, index1;

			char r= keyWord.charAt( i% keyWord.length());
			char c= encrypted.charAt(i);

			for(int row =0; row<matrix.length ; row++)
				if(matrix[row][0] == r)
				index= row;
			for(pos=0 ; pos< matrix.length ; pos++)
				if(matrix[index][pos] == c)
				index1 =pos;
		}// end for
		return decryption.toString();

This is my openFile method code:

JFileChooser openDialog = new JFileChooser(".");
		int selection = openDialog.showOpenDialog(null);

		if(selection == openDialog.APPROVE_OPTION)
			File selected = openDialog.getSelectedFile();
			Scanner kb= new Scanner(selected);

			String key= kb.next();

			String text= kb.nextLine();

			return text;

can anybody see why am I getting a null!

You didn't use setSelectedFile(File) but you use getSelectedFile()??? Then what file are you actually selecting? Here is the JFileChooser API.