Jump to content

Assume

Member
  • Posts

    77
  • Joined

  • Last visited

Awards

This user doesn't have any awards

Assume's Achievements

  1. Okay so here's what you're doing wrong. #1. Use String#equalsIgnoreCase #2. Use braces to surround the if statements if(ans.equalsIgnoreCase("d") { //all code for division here }
  2. All good. I was just pointing it out so the OP wouldn't get confused on why it wouldn't run if he tried it (Eclipse doesn't give correct information if you pass a primitive) @OP When using Lists, Maps, Collections, or really any data structure, you need to use the object version of the primitive. IE: int, Integer boolean, Boolean, long, Long, double, Double float, Float char, Character Arrays in Java are objects so you can do int[], long[], boolean[] etc etc
  3. Your first class snippet won't compile as you can't pass primitives in Lists or maps or w/e. What he's aid is true though. It's a means of creating something that could relate to something your program will do. IE: making a voting booth. You may have a people object that stores name, social security number, and age. It may have a method called setVote that takes a candidates name as a parameter.
  4. I would have to disagree. Java, having no pointers, a garbage collector, and the Oracle Java Docs (imo, the best documentation of any language), is a breeze to learn.
  5. HTML is not a language. It is a markup language as annotated by it's name. Hypertext MARKUP language. It contains no logic.
  6. Triple 1080p means moving your head more to see everything you are working on.
  7. So much money is different for different people. Some people will think that spending $200 on shoes is absolutely insane, but others will find it normal.
  8. I would start with a high level language (Java or Python) and then move onto lower level languages (c++ or c).
  9. Post everything. You have a lot of code missing.
  10. Is that a Runescape private server?
  11. What class are you extending? You are calling super.callPattern(). Did you write the class you are extending? EDIT: Use code tags and post everything you have. Some stuff is missing and the code is hard to read in its current state.
  12. I keep trying to get into IntelliJ but I just can't get used to it. I'm dreading AP Computer Science next year. I hear they require everyone to use BlueJ (The worst IDE ever).
  13. Filco Majestouch-2 TKL Func MS-3 Sennheiser HD598's
  14. URLUtil.java package org.assume.api.networking;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.URL;import java.util.ArrayList;import java.util.Collection;import org.assume.api.types.URLW;public class URLUtil{ private String url_; private String extension_; public URLUtil(String url, String extension) { this.url_ = url; this.extension_ = extension; } public URLUtil(String url) { this.url_ = url; this.extension_ = ""; } public URLW[] getFileUrls() throws IOException { Collection<URLW> list = new ArrayList<URLW>(); BufferedReader in = new BufferedReader( new InputStreamReader(new URL(url_).openStream())); String line; while((line = in.readLine()) != null) { for(String d : line.split(" ")) { /* If the line of html contains the file extension that is passed it will execute the code below * Since a line of html could look like this http://someurlhere.com/blah/blah <src>http://someurlhere.com/image.jpg</src> * You need to split at each space on the line (a url can't have a space) and check once again until you get to the end of the line * When it find a correctly formatted URL it creates a substring starting at http and ending at the file extension. * Since it will remove the file extension on the END of the url, you need to add it back after creating the substring * It does not remove http when creating a substring * It does not matter if you pass '.jpg' or 'jpg'. You can do either */ if(d.contains(extension_) && d.contains("http")) { list.add(new URLW(new URL(d.substring(d.indexOf("http"), d.indexOf(extension_)).concat(extension_)))); } } } in.close(); return list.toArray(new URLW[list.size()]); } public URLW[] getImageUrls() throws IOException { Collection<URLW> list = new ArrayList<URLW>(); BufferedReader in = new BufferedReader( new InputStreamReader(new URL(url_).openStream())); String line; while ((line = in.readLine()) != null) { if(line.contains(".jpg") || line.contains(".gif") || line.contains(".jpeg") || line.contains(".png") || line.contains(".bmp") || line.contains(".webp")) { /* If the line of html contains any of the above image file extensions it will execute the code below * Since a line of html could look like this http://someurlhere.com/blah/blah <src>http://someurlhere.com/image.jpg</src> * You need to split at each space on the line (a url can't have a space) and check once again until you get to the end of the line * When it find a correctly formatted URL it creates a substring starting at http and ending at the file extension. * Since it will remove the file extension on the END of the url, you need to add it back after creating the substring * It does not remove http when creating a substring */ for(String d : line.split(" ")) { if(d.contains(".jpg") && d.contains("http")) { list.add(new URLW(new URL(d.substring(d.indexOf("http"), d.indexOf(".jpg")).concat(".jpg")))); } else if(d.contains(".gif") && d.contains("http")) { list.add(new URLW(new URL(d.substring(d.indexOf("http"), d.indexOf(".gif")).concat(".gif")))); } else if(d.contains(".png") && d.contains("http")) { list.add(new URLW(new URL(d.substring(d.indexOf("http"), d.indexOf(".png")).concat(".png")))); } else if(d.contains(".jpeg") && d.contains("http")) { list.add(new URLW(new URL(d.substring(d.indexOf("http"), d.indexOf(".jpeg")).concat(".jpeg")))); } else if(d.contains(".bmp") && d.contains("http")) { list.add(new URLW(new URL(d.substring(line.indexOf("http"), d.indexOf(".bmp")).concat(".bmp")))); } else if(d.contains(".webp") && d.contains("http")) { list.add(new URLW(new URL(d.substring(d.indexOf("http"), d.indexOf(".webp")).concat(".webp")))); } } } } in.close(); return list.toArray(new URLW[list.size()]); }}URLW.java package org.assume.api.types;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.URL;import java.net.URLConnection;public class URLW{ private URL url_; public URLW(URL url) { this.url_ = url; } public String getFileExtension() { return this.url_.toString().substring(this.url_.toString().lastIndexOf(".")); } public String getFileName() { return this.url_.toString().substring(this.url_.toString().lastIndexOf("/")); } public boolean download(String fileName) { /* The file name is the FULL path * ex. System.getProperty("user.home")+ * File.separator+ * "Users"+ * File.separator+ * "Adam"+ * File.separator+ * "documents"+ * File.separator+ * "food"+ * "food.png"); */ OutputStream out = null; URLConnection connection = null; InputStream in = null; try { out = new BufferedOutputStream(new FileOutputStream(fileName)); connection = this.getUrl().openConnection(); in = connection.getInputStream(); byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (in != null) { in.close(); } if (out != null) { out.close(); } } catch (IOException e) { } } return new File(fileName).exists(); } @Override public String toString() { return this.url_.toString(); } public URL getUrl() { return url_; }}(URL is a final class so you can't write a wrapper. This is the next best thing)Usage: import java.io.IOException;import org.assume.api.networking.URLFinder;public class Test{ public static void main(String[] args) throws IOException { for(URLW d : new URLUtil("http://imgur.com").getImageUrls()) { System.out.println(d.toString()); } }}Output: import java.io.IOException;import org.assume.api.networking.URLUtil;public class Test{ public static void main(String[] args) throws IOException { for(URLW d : new URLUtil("http://engagdet.com", ".jpg").getFileUrls()) { System.out.println(d.toString()); } }}Output: Downloading: import java.io.File;import java.io.IOException;import org.assume.api.networking.URLUtil;import org.assume.api.types.URLW;public class Test{ public static void main(String[] args) throws IOException { for(URLW d : new URLUtil("https://imgur.com").getImageUrls()) { System.out.println(d.toString()); if(d.download(System.getProperty("user.home")+ File.separator+ "Test"+ File.separator+ d.getFileName())) { System.out.println("Success"); } } }}Output: **Ignore the fucked up formatting. I don't know why the code tags are so shit.
  15. I'm just on Tribot. I could never do anything on PB as I have no experience with EoC (the new combat system) so my scripts would be absolutely terrible. Tribot only does RuneScape 2007. When I say money, I mean a real amount of money (I out earned my teachers last month).
×