public static File getAttachment(HttpURLConnection request)throws Exception
	{
		
		int status = request.getResponseCode();
	
		InputStream is = request.getInputStream();
		String line = "";
		String responseLine = "";
		int inByte;
		
		BufferedReader br;

		if(status == 200)
		{
			
			String header = request.getHeaderField("Content-Disposition"); //No I18N

			int beginIndex = header.indexOf("\"");

			int lastIndex = header.lastIndexOf("\"");

			String fileName = header.substring(beginIndex+1, lastIndex);

			File file = new File(fileName);

			FileOutputStream fos = new FileOutputStream(file);
			
			
			try
			{
				while ((inByte = is.read()) != -1) 
				{
					fos.write(inByte);
				}
				
			
			}
			catch(IOException e)
			{
				throw new IOException();
			}
		
			finally
			{
				is.close();
				fos.flush();
				fos.close();
			}
			
			return file;
		}
		
		if(status == 204)
		{
			throw new ProjectsException(status, "No content for the requested resource.");	//No I18N
		}
	
		else
		{
			br = new BufferedReader(new InputStreamReader(request.getErrorStream()));
		
			while ((line = br.readLine()) != null)
			{
				responseLine += line;
			}
	
			JSONObject resp = new JSONObject(responseLine.trim());
			
			JSONObject error = resp.getJSONObject("error");
		
			throw new ProjectsException(error.getInt("code"), error.getString("message")); //No I18N
		}
		
	}