Thread: File checking Loop, Rep + Thanks

Results 1 to 6 of 6
  1. #1 File checking Loop, Rep + Thanks 
    Banned
    Join Date
    Oct 2011
    Posts
    860
    Thanks given
    371
    Thanks received
    214
    Rep Power
    0
    Ok so I have this void which is simply written:

    Code:
    nty leechers
    I want the screenshots to take one, it makes it screen00001, the next one is screen00002, the next screen00003, but I don't know how to make a loop check if the file exists and write the int.

    Basically what I need you to do is write something that will check for the existing screenshots, and then choose the next number. so it will go 00001, 00002, and so on.

    Rep and thanks to somebody who makes the int or method!

    (I'm god awful with loops)
    Reply With Quote  
     

  2. #2  
    Community Veteran

    WH:II:DOW's Avatar
    Join Date
    Dec 2007
    Age
    34
    Posts
    2,017
    Thanks given
    145
    Thanks received
    872
    Rep Power
    4275
    File dasOutputz = null;

    for (int i = 0; i < something; i++) {
    File daone2envy = new File("screen000002.jpeg");
    if (!daone2envy.exists()) {
    dasOutputz = daone2envy;
    break;
    }
    }
    if (dasOutput != null) {

    }

    (Don't use this, it's horrible)
    hella titties
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Oct 2011
    Posts
    860
    Thanks given
    371
    Thanks received
    214
    Rep Power
    0
    Quote Originally Posted by WH:II:DOW View Post
    File dasOutputz = null;

    for (int i = 0; i < something; i++) {
    File daone2envy = new File("screen000002.jpeg");
    if (!daone2envy.exists()) {
    dasOutputz = daone2envy;
    break;
    }
    }
    if (dasOutput != null) {

    }

    (Don't use this, it's horrible)
    All it needs to do is generate and int, and if the int exists(screenshot exists) try the next number till it gets one right
    Reply With Quote  
     

  4. #4  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    would be easier if you didn't have them empty 0's in there

    Code:
    public int getScreenshotID() {
    int id = 0;
    while(true) {
       File f = new File("screenshot"+id+".jpeg");
       if (f.exists())
           id++;
        else
          return id;
    }
    return id;
    }
    i think that's right
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Banned
    Join Date
    Oct 2011
    Posts
    860
    Thanks given
    371
    Thanks received
    214
    Rep Power
    0
    Quote Originally Posted by Harlan View Post
    would be easier if you didn't have them empty 0's in there

    Code:
    public int getScreenshotID() {
    int id = 0;
    while(true) {
       File f = new File("screenshot"+id+".jpeg");
       if (f.exists())
           id++;
        else
          return id;
    }
    return id;
    }
    i think that's right
    Code:
    RSApplet.java:329: unreachable statement
                    return id;
    EDIT: fixed error and.. omfg.. IT WORKED FUCKING LOVE YOU HARLAN

    read my sig
    Reply With Quote  
     

  7. #6  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    Quote Originally Posted by Paradox_ View Post
    Code:
    RSApplet.java:329: unreachable statement
                    return id;
    EDIT: fixed error and.. omfg.. IT WORKED FUCKING LOVE YOU HARLAN

    read my sig
    haha, no problem

    nice sig
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 3
    Last Post: 11-27-2011, 04:37 AM
  2. Checking if file contains
    By rexz0rd in forum Application Development
    Replies: 6
    Last Post: 11-20-2011, 09:06 PM
  3. Replies: 14
    Last Post: 08-27-2010, 06:19 AM
  4. Replies: 7
    Last Post: 04-15-2009, 06:21 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •