I'm new to DaniWeb, so I don't really know much. Excuse me if I seem really rude or anything.

Anyways, I'm having trouble with an android app I'm building. My program seems to force close whenever I put in:

String fileContents = getFileContents("http://www.youtube.com/watch?v="+code);
		fileContents = fileContents.substring(fileContents.indexOf("\'VIDEO_ID\': "+"\""+code+"\""),fileContents.indexOf("yt.setMsg({"));
		String[] settings = fileContents.split("fmt_url_map");
		settings = settings[settings.length-1].split("\"");
		String map = settings[2];
		map = map.replace("\\/", "/").replace("\\u0026", "&");
		fmtMap = map.split("[,|]+");
		hash = new HashMap<Integer, String>();
		for(int i = 0; i< fmtMap.length/2; i ++) {
			hash.put(new Integer(Integer.parseInt(fmtMap[2*i])),fmtMap[2*i+1]);

My getFileContents() function is as follows:

public static String getFileContents(String path) {
		InputStreamReader instream = null;
		URL url = null;
		URLConnection urlConn = null;
		try {
			url = new URL(path);
			try {
				urlConn = url.openConnection();
				instream = new InputStreamReader(urlConn.getInputStream());
			} catch (IOException e) {
				// TODO Auto-generated catch block
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
		String separator = System.getProperty("line.separator");
		StringBuffer contents = new StringBuffer();
		try {
			BufferedReader f = new BufferedReader(instream);
			try {
				String line = null;
				while((line = f.readLine()) != null) {
			finally {
		catch (IOException ex) {
		String text = contents.toString();
		return text;

I suspect this is because I'm porting Java code directly to Android, but I don't know how to do it otherwise.

If anybody can help me, that would be great.

Well, you could use the NDK for native java, though it's not exactly recommended. You could also try reposting your code with thorough commentary so that we don't have to interpret every single line ourselves <3