List of usage examples for java.net MalformedURLException printStackTrace
public void printStackTrace()
From source file:gov.nih.nci.nbia.StandaloneDMV1.java
void submitUserCredential(String usrId, String password) { List<String> seriesInfo = null; try {//from w w w . j av a 2 s. c om seriesInfo = connectAndReadFromURL(new URL(serverUrl), fileLoc + basketId.substring(0, basketId.length() - 2)); } catch (MalformedURLException e1) { e1.printStackTrace(); } try { int lastRecInx = seriesInfo.size() - 1; String[] strResult = new String[seriesInfo.size()]; String key = seriesInfo.get(lastRecInx); String encryptedPassword = encrypt(password, key); if (loggedIn(userId, encryptedPassword, seriesInfo.get(lastRecInx - 2), seriesInfo.get(lastRecInx - 1))) { seriesInfo.remove(lastRecInx); seriesInfo.remove(lastRecInx - 1); seriesInfo.remove(lastRecInx - 2); seriesInfo.toArray(strResult); List<SeriesData> seriesData = JnlpArgumentsParser.parse(strResult); DownloadManagerFrame manager = new DownloadManagerFrame(userId, encryptedPassword, includeAnnotation, seriesData, serverUrl, noOfRetry); manager.setTitle(winTitle); manager.setDefaultDownloadDir(System.getProperty("user.home") + File.separator + "Desktop"); manager.setVisible(true); frame.setVisible(false); } else { statusLbl.setText("Invalid User name and/or password. Please try it again."); statusLbl.setForeground(Color.red); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.siahmsoft.soundwaper.net.SoundcloudApi.java
private List<Track> getUserTracks(String username) { URL url = null;/* www.j a va 2 s .co m*/ List<Track> tracks; StringBuilder builder = new StringBuilder(SoundcloudApi.API_ENDPOINT_URL); builder.append('?').append("consumer_key=").append(SoundcloudApi.API_KEY).append('&').append("q=") .append(username); try { url = new URL(builder.toString()); Log.d(TAG, "Requesting static image from Soundcloud=[" + url + "]"); } catch (MalformedURLException error) { error.printStackTrace(); } tracks = retrieveTracks(url); if (tracks == null) { return new ArrayList<Track>(); } TracksCache.putAll(username, tracks); return tracks; }
From source file:com.siahmsoft.soundwaper.net.SoundcloudApi.java
private Pair<Bitmap, Track> getRandomBitmap(List<Track> tracks) { Track track = null;/* www. ja v a 2 s .c o m*/ Bitmap bitmap = null; int randomIndex = 0; if (tracks.size() > 0) { randomIndex = roulette.nextInt(tracks.size()); track = tracks.get(randomIndex); if (track != null) { try { bitmap = retrieveBitmap(new URL(track.getWaveformUrl())); } catch (MalformedURLException e) { e.printStackTrace(); } } } return new Pair<Bitmap, Track>(bitmap, track); }
From source file:com.mcapanel.web.controllers.InstallController.java
@SuppressWarnings("unchecked") public boolean process() throws IOException { if (isMethod("POST")) { includeIndex(false);// w w w . j a v a 2s . c om mimeType("application/json"); JSONObject out = new JSONObject(); if (!config.getBoolean("installed", false)) { String serverIp = request.getParameter("serverip"); String webPort = request.getParameter("webport"); String cbName = request.getParameter("cbname"); String cbFile = request.getParameter("cbfile"); String cbInstall = request.getParameter("cbinstall"); String mcname = request.getParameter("mcname"); String mcpass = request.getParameter("mcpass"); String mcpassconf = request.getParameter("mcpassconf"); String licemail = request.getParameter("licemail"); String lickey = request.getParameter("lickey"); if (mcpass.equals(mcpassconf)) { User u = new User(mcname, mcpass, RandomStringUtils.randomAlphanumeric(8), request.getRemoteAddr().equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : request.getRemoteAddr()); u.setGroupId(db.find(Group.class).where().ieq("group_name", "Admin").findUnique().getId()); u.setWhitelisted(true); db.save(u); loginUser(u); Server server = new Server(cbName, cbFile); db.save(server); BukkitServer bukkitServer = new BukkitServer(server); AdminPanelWrapper.getInstance().servers.put(server.getId(), bukkitServer); request.getSession().setAttribute("chosenServer", server.getId()); bukkitServer.setupBackups(); config.setValue("installed", "true"); config.setValue("server-ip", serverIp); config.setValue("web-port", webPort); config.setValue("license-email", licemail); config.setValue("license-key", lickey); config.saveConfig(); //ap.install(); final BukkitVersion bv = BukkitVersion.getVersion(cbInstall); if (bv != null) { new Thread(new Runnable() { public void run() { try { System.out.println("Downloading CraftBukkit..."); File cbFile = new File("craftbukkit.jar"); FileUtils.copyURLToFile(new URL(bv.getUrl()), cbFile); config.setValue("server-jar", cbFile.getAbsolutePath()); config.saveConfig(); //ap.install(); System.out.println("Done downloading CraftBukkit!"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }).start(); } out.put("good", "Successfully saved all installation settings.<br />It is recommended to create another user so you can see what they see."); } else out.put("error", "The passwords that you entered do not appear to match."); } else out.put("error", "You are not allowed to do that."); response.getWriter().println(out.toJSONString()); return true; } return error(); }
From source file:com.qiqi8226.http.MainActivity.java
private void onBtnClientPost() { new AsyncTask<String, String, Void>() { @Override//from ww w. j a va 2s . co m protected Void doInBackground(String... params) { try { HttpPost post = new HttpPost(params[0]); List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>(); // list.add(new BasicNameValuePair("test", "test")); post.setEntity(new UrlEncodedFormEntity(list)); HttpResponse response = client.execute(post); String tmp = EntityUtils.toString(response.getEntity()); publishProgress(tmp); } catch (MalformedURLException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onProgressUpdate(String... values) { tv.setText(values[0]); } }.execute("http://www.baidu.com/"); }
From source file:com.qiqi8226.http.MainActivity.java
private void onBtnGet() { new AsyncTask<String, String, Void>() { @Override//from ww w . j a v a2 s.co m protected Void doInBackground(String... params) { try { String tmp = URLEncoder.encode("API", "utf-8"); URL url = new URL(params[0] + tmp); URLConnection conn = url.openConnection(); InputStream is = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { publishProgress(line); } br.close(); is.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onProgressUpdate(String... values) { tv.append(values[0] + "\n"); } }.execute( "http://fanyi.youdao.com/openapi.do?keyfrom=qiqi8226&key=1401459950&type=data&doctype=xml&version=1.1&q="); }
From source file:icevaluation.ICEvaluation.java
public double calculateHits(String query, String bingAPIKey) { //update key use by incrementing key use Integer n = keyMap.get(bingAPIKey); if (n == null) { n = 1;//from ww w. ja va2 s . c o m } else { n = n + 1; } keyMap.put(bingAPIKey, n); double icHit = 1; String searchText = query; searchText = searchText.replaceAll(" ", "%20"); String accountKey = bingAPIKey; byte[] accountKeyBytes = Base64.encodeBase64((accountKey + ":" + accountKey).getBytes()); String accountKeyEnc = new String(accountKeyBytes); URL url; try { url = new URL("https://api.datamarket.azure.com/Bing/Search/v1/Composite?Sources=%27Web%27&Query=%27" + searchText + "%27&$format=JSON"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Authorization", "Basic " + accountKeyEnc); //conn.addRequestProperty(accountKeyEnc, "Mozilla/4.76"); BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); StringBuilder sb = new StringBuilder(); String output; //System.out.println("Output from Server .... \n"); //write json to string sb while ((output = br.readLine()) != null) { //System.out.println("Output is: "+output); sb.append(output); } conn.disconnect(); //find webtotal among output int find = sb.indexOf("\"WebTotal\":\""); int startindex = find + 12; // System.out.println("Find: "+find); int lastindex = sb.indexOf("\",\"WebOffset\""); String ICString = sb.substring(startindex, lastindex); //System.out.println(ICString); icHit = Double.valueOf(ICString); } catch (MalformedURLException e1) { icHit = 1; e1.printStackTrace(); } catch (IOException e) { icHit = 1; e.printStackTrace(); } return icHit; }
From source file:com.zergiu.tvman.shows.search.AddShowFlowService.java
/** * @return//from w w w . j av a 2 s.c o m */ private void fillLanguagesTable() { log.debug("going to go to TVDB.com to get a list of languages"); List<TVDBLanguage> languages = new ArrayList<TVDBLanguage>(); URL url = null; try { url = new URL("http://www.thetvdb.com/api/CAC7D918A2D6A58F/languages.xml"); InputStream in = url.openStream(); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); SearchLanguagesHandler handler = new SearchLanguagesHandler(languages); parser.parse(in, handler); in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } tvdbLanguageService.addLanguages(languages); }
From source file:com.qiqi8226.http.MainActivity.java
private void onBtnPost() { new AsyncTask<String, String, Void>() { @Override/*w w w . java 2 s .c o m*/ protected Void doInBackground(String... params) { URL url; try { url = new URL(params[0]); URLConnection conn = url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream())); bw.write(""); bw.flush(); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = br.readLine()) != null) { publishProgress(line); } br.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onProgressUpdate(String... values) { tv.append(values[0] + "\n"); } }.execute("http://www.baidu.com/"); }