Java Code Examples for java.net.URLConnection#setAllowUserInteraction()
The following examples show how to use
java.net.URLConnection#setAllowUserInteraction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IridiumSkyblock.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
public void downloadConfig(String language, File file) { getLogger().info("https://iridiumllc.com/Languages/" + language + "/" + file.getName()); try { URLConnection connection = new URL("https://iridiumllc.com/Languages/" + language + "/" + file.getName()).openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); connection.setAllowUserInteraction(false); connection.setDoOutput(true); InputStream in = connection.getInputStream(); if (!file.exists()) file.createNewFile(); OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); byte[] buffer = new byte[1024]; int numRead; while ((numRead = in.read(buffer)) != -1) { out.write(buffer, 0, numRead); } in.close(); out.close(); } catch (IOException e) { IridiumSkyblock.getInstance().getLogger().info("Failed to connect to Translation servers"); } }
Example 2
Source File: PuzzleDownloadListener.java From shortyz with GNU General Public License v3.0 | 6 votes |
private InputStream OpenHttpConnection(URL url, String cookies) throws IOException { InputStream in = null; URLConnection conn = url.openConnection(); if ((cookies != null) && !cookies.trim() .equals("")) { conn.setRequestProperty("Cookie", cookies); } conn.setAllowUserInteraction(false); conn.connect(); in = conn.getInputStream(); return in; }
Example 3
Source File: URLResourceData.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private void readMetaData() throws IOException { if ( metaDataOK ) { if ( ( System.currentTimeMillis() - lastDateMetaDataRead ) < URLResourceData.getFixedCacheDelay() ) { return; } if ( isFixBrokenWebServiceDateHeader() ) { return; } } final URLConnection c = url.openConnection(); c.setDoOutput( false ); c.setAllowUserInteraction( false ); if ( c instanceof HttpURLConnection ) { final HttpURLConnection httpURLConnection = (HttpURLConnection) c; httpURLConnection.setRequestMethod( "HEAD" ); } c.connect(); readMetaData( c ); c.getInputStream().close(); }
Example 4
Source File: Http.java From smslib-v3 with Apache License 2.0 | 6 votes |
List<String> HttpPost(URL url) throws IOException { List<String> responseList = new ArrayList<String>(); URL cleanUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getPath()); Logger.getInstance().logInfo("HTTP POST: " + cleanUrl, null, null); URLConnection con = cleanUrl.openConnection(); con.setDoOutput(true); OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream()); out.write(url.getQuery()); out.flush(); con.setAllowUserInteraction(false); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) responseList.add(inputLine); out.close(); in.close(); return responseList; }
Example 5
Source File: WebReader.java From FxDock with Apache License 2.0 | 5 votes |
public byte[] readBytes(URL url) throws Exception { URLConnection c = url.openConnection(); // if(c instanceof HttpsURLConnection) // { // // TODO set gullible access handler? // } c.setConnectTimeout(connectTimeout); c.setReadTimeout(readTimeout); c.setDoOutput(false); c.setAllowUserInteraction(false); c.setUseCaches(false); c.connect(); //D.print("content-encoding: " + c.getContentEncoding()); // text/html // image/jpeg // text/plain //D.print("content-type: " + c.getContentType()); InputStream in = c.getInputStream(); try { return CKit.readBytes(in, maxContentLength); } finally { CKit.close(in); } }
Example 6
Source File: ResourceGroovyMethods.java From groovy with Apache License 2.0 | 5 votes |
/** * Creates an inputstream for this URL, with the possibility to set different connection parameters using the * <i>parameters map</i>: * <ul> * <li>connectTimeout : the connection timeout</li> * <li>readTimeout : the read timeout</li> * <li>useCaches : set the use cache property for the URL connection</li> * <li>allowUserInteraction : set the user interaction flag for the URL connection</li> * <li>requestProperties : a map of properties to be passed to the URL connection</li> * </ul> * * @param parameters an optional map specifying part or all of supported connection parameters * @param url the url for which to create the inputstream * @return an InputStream from the underlying URLConnection * @throws IOException if an I/O error occurs while creating the input stream * @since 1.8.1 */ private static InputStream configuredInputStream(Map parameters, URL url) throws IOException { final URLConnection connection = url.openConnection(); if (parameters != null) { if (parameters.containsKey("connectTimeout")) { connection.setConnectTimeout(DefaultGroovyMethods.asType(parameters.get("connectTimeout"), Integer.class)); } if (parameters.containsKey("readTimeout")) { connection.setReadTimeout(DefaultGroovyMethods.asType(parameters.get("readTimeout"), Integer.class)); } if (parameters.containsKey("useCaches")) { connection.setUseCaches(DefaultGroovyMethods.asType(parameters.get("useCaches"), Boolean.class)); } if (parameters.containsKey("allowUserInteraction")) { connection.setAllowUserInteraction(DefaultGroovyMethods.asType(parameters.get("allowUserInteraction"), Boolean.class)); } if (parameters.containsKey("requestProperties")) { @SuppressWarnings("unchecked") Map<String, CharSequence> properties = (Map<String, CharSequence>) parameters.get("requestProperties"); for (Map.Entry<String, CharSequence> entry : properties.entrySet()) { connection.setRequestProperty(entry.getKey(), entry.getValue().toString()); } } } return connection.getInputStream(); }
Example 7
Source File: URLResourceData.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { try { final URLConnection c = url.openConnection(); c.setDoOutput( false ); c.setAllowUserInteraction( false ); c.connect(); if ( isFixBrokenWebServiceDateHeader() == false ) { readMetaData( c ); } return c.getInputStream(); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to open URL connection", e ); } }
Example 8
Source File: Http.java From smslib-v3 with Apache License 2.0 | 5 votes |
List<String> HttpGet(URL url) throws IOException { List<String> responseList = new ArrayList<String>(); Logger.getInstance().logInfo("HTTP GET: " + url, null, null); URLConnection con = url.openConnection(); con.setAllowUserInteraction(false); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) responseList.add(inputLine); in.close(); return responseList; }
Example 9
Source File: HTTPGateway.java From smslib-v3 with Apache License 2.0 | 5 votes |
List<String> HttpGet(URL url) throws IOException { List<String> responseList = new ArrayList<String>(); Logger.getInstance().logInfo("HTTP GET: " + url, null, getGatewayId()); URLConnection con = url.openConnection(); con.setConnectTimeout(20000); con.setAllowUserInteraction(false); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) responseList.add(inputLine); in.close(); return responseList; }