Where to put .txt file for easy I/O

Hi,
I'm creating a program to run psychological experiments, and I want to make it easy for future researchers to change the lists of stimuli.
I'm planning on having a set of .txt/.csv files containing the lists, which can be easily modified by anyone. My question is, where do I put them?
My guess is the easiest solution would be to put them in the same folder as the .jar file, but not to actually include them in the .jar file, as this would make it difficult to edit. So how would I refer to the path name of the list in my program? And, when testing the program as it's being written, should I put the files in the /dist folder that NetBeans created?
Second question: I want to find and load any and all txt files that may be in the folder (assuming this is where they will go). I won't know ahead of time how many lists there will be. What's the easiest way to do this?
Thanks!

Alright, two questions:
1) To find the files, can I just use some modified form of
String[] filenames;
          File f = new File(".");
          filenames = f.list();I assume that there's some way of doing the same thing one level up on the directory tree, and then selecting only those files that end in .csv? Is it preferable to use the method that was mentioned above?
2) I'm still a little confused as to where the files should go. Here in NetBeans, when I use the command above it gives me everything in the very bottom folder, including /dist, /src and everything else in that folder, even though the .jar file itself is located in /dist.
Is NetBeans not actually running the program from the .jar file?
When I distribute the code, should I assume that the "File f = new File(".");" will give me everything in the folder where the .jar is sitting?
[Edit: I've solved #2 myself -- sorry about that. The answer seems to be "yes" and "yes": when testing, I should put my .csv files in the bottom folder, when distributing, I should put them in the folder with the .jar file. I can't do it ahead of time, as NetBeans recreates the /dist folder each time the project is re-built.]
Thanks!

Similar Messages

  • Where to put .txt file with SimpleInput

    Hello everyone,
    I'm rather new to Java and have a slight problem. The thing is that I need to write an app that can read a text file in this format:
    2
    Orc
    name = Gnorck
    experience = 20
    maxHealthPoints = 50
    healthPoints = 30
    maxBerserk = 9
    berserk = 7
    Human
    name = Aragorn
    experience = 45
    maxHealthPoints = 40
    healthPoints = 30
    maxGreed = 20
    greed = 10
    The first number is de number of characters in the file and after that every character is described in 7 lines.
    Now the application has to be able to read the file. I've choosen to first just make a list of characters. A friend helped me with this code but I'm not completely sure if I know how it works. The code:
    package RPGApplicatie;
    import java.util.*;
    public class Karakters {
         //Constructor
         public Karakters(int size){
              karakters = new ArrayList(size);
         //Methode voor het toevoegen van een karakter
         public void voegToe(Karakter k){
              karakters.add(k);
         public static Karakters readFile(String filename) throws ClassNotFoundException, RuntimeException, InstantiationException, IllegalAccessException{
              SimpleInput file = new SimpleInput(filename);
              int size = file.nextInt();
              Karakters result = new Karakters(size);
              for(int i = 0; i < size ; i++) {
                   Class c = Class.forName(file.nextLine());
                   result.voegToe((Karakter)c.newInstance());
              return result;
         //Variabelen aanmaken
         private ArrayList<Karakter> karakters;
    }First question: I have the classes Karakter (which is the superclass for class Human and Orc), Human and Orc. So does the method forName scan for strings that are also classes? Like so it scans the file and when it comes across a line that says either 'Orc' or 'Human' it adds it to the list?
    Second question: Where to put the text file that holds the data? I now have it in the same folder called test.txt. I use this code to run it:
    package RPGApplicatie;
    public class RPGApplicatie {
         public static void main(String[] args) throws ClassNotFoundException, RuntimeException, InstantiationException, IllegalAccessException {
              Karakters.readFile("test.txt");
    }Thanks in advance! If more info is needed I can post that.
    Regards,
    Sander

    I assume you have defined your Human and Orc classes to include fields name, experience, etc and a constructor that takes these values as parameters?
    You can remove the Class.forName() method altogether. Example:
    int count = file.readInt();
    // define variables for Karakter values (name, experience etc.)
    for (int i = 0; i < count; i++)
      String characterClass = file.readLine();
      // read common character components
      if (characterClass.equals("Human")
        // read human specific components
        karakters.add(new Human(...));
      if (characterClass.equals("Orc")
        // create Orc
    //...Cheers

  • Where is the data file for the address book located, I need to restore mine from backup but don't know where it is.

    Where is the data file for the address book located, I need to restore mine from backup but don't know where it is to do so.  Putting my Mac Pro onto icloud synching contacts resulted in duplicate and triplicates of the same cards.  I have a few THOUSAND contacts and the last time this happened was on mobile me.  that had a function where you could replace info on the mobile me server with info on the computer.  I see no way to do that on the new cloud.

    In the stupidly hidden user's Library->/Application Support/AddressBook/ labeled as AddressBook-v22.abcddb
    For TM restores, see Pondini's TM FAQs for starters, since I don't use TM.

  • How can i put txt files in my i phone 4

    how can i put txt files in my i phone 4

    There are many apps for this.
    I use idisk with mobileme.
    You can search the apps store or do a forum search and find several others.

  • Where are the backup files for my iPad located on my macbook pro with maverick ?

    where are the backup files for my iPad located on my macbook pro with maverick ?

    As an addendum, if I need to, and hopefully won't, unless I switch computers, how can I revert from a copy of a different backup?  Thanks. :-)

  • How do I get Firefox to ask me where to put a file I wish to download

    When I download a file, Firefox puts it somewhere. I want to be able to tell it where to put that file each and every time.

    Options > General - Downloads = '''Always ask me where to save files'''

  • Urgent where i put this code for delete

    hi master
    sir this code is right for my requirment but when i put on_delete event system not respons or not delete record
    where i put this code for conditional deletion
    this is my code
    declare
         recno number;
    begin
    if :system.cursor_block='accbal' then
    delete accbal where accid=:chartofacc.accid;
         go_block('chartofacc');
         next_record;
    elsif :system.cursor_block='chartofacc' then
         select count(*) into recno from accbal where accid=:chartofacc.accid;
         if recno=0 then
         delete_record;
         go_block('chartofacc');
         previous_record;
         else
         message ('system found matching record then no delete master record');
         message ('system found matching record then no delete master record');
         end if;
    end if;
    end;
    please gide me which event i use
    thanking you
    aamir

    Hello,
    The ON-DELETE triger fires only after a COMMIT statment and only for those records that have been deleted in the block.
    Francois

  • [svn] 4561: Updated error. txt files for goodValidatorTest and patternFilterLoggingMessageFilterTest to fix failure on appservers other than Tomcat

    Revision: 4561
    Author: [email protected]
    Date: 2009-01-16 10:59:37 -0800 (Fri, 16 Jan 2009)
    Log Message:
    Updated error.txt files for goodValidatorTest and patternFilterLoggingMessageFilterTest to fix failure on appservers other than Tomcat
    checkintests: pass
    Modified Paths:
    blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/messagingService/validation/good ValidatorTest/error.txt
    blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/messagingService/validation/patt ernFilterLoggingMessageFilterTest/error.txt

    Dude this worked fantastic.   Thank you for posting.

  • Where is the default file for SVG filters in Illustrator CC?

    Where is the default file for SVG filters in Illustrator CC?

    User \ Library \ Application Support \ Adobe \ en_EN \ Adobe SVG Filter.svg
    it's:
    User \ Library \ Application Support \ Adobe \ Adobe Illustrator 17 \ en_EN \ Adobe SVG Filter.svg
    Note that youneed to unhide the Library folder on Mac OS X Tiger and up

  • Where are the sample files for dreamweaver cs 5.5 on Adobe TV?

    where are the sample files for Dreamweaver cs 5.5 on Adobe TV? video says there there, but there not! Video even shows where to find them, but there still not there! Were they just to big for Adobes servers to handle so the had to take them down to make space?  : )  Please help, could really use them. Thanks! : )

    CS5.5 is now 4 versions behind CS6, CC and CC2014.
    This tutorial was written for CS5 and it works with CS5.5. You'll find the supporting files for it under Sample Files on the right.
    Building your first dynamic website – Part 1: Setting up the site and database | Adobe Developer Connection
    Nancy O.

  • Where to put properties files in EJB?

    is there a good standard place to put properties files for EJB?

    files. i wanted to jar everything together in a single
    ejb jar, and need to know if there is a standard or
    good place to keep those properties files so that
    whenever i move the ejb jar i dont have to worry about
    the paths to find those properties files.??? Both of my suggestions allow what you want. Neither one requires knowing any kind of file path. For example, packaging a properties files as my/fancy/data.properties entry in a jar will allow loading it as Properties ps = new Properties();
    ps.load (getClass().getResource("/my/fancy/data.properties").openStream(); (better code would also close() the stream in a finally block)
    The above depends on how the jar was packaged, not on its actual disk location.
    What's more, Class.getResource() also allows for package name-relative resource lookup which is convenient sometimes: http://www.javaworld.com/javaworld/javaqa/2002-11/02-qa-1122-resources.html

  • Where is the plist file for the Finder option "Always Show Extensions"?

    Where is the plist file for the Finder option "Always Show Extensions"?
    I am designing a new master NetRestore image for Leopard. I have all my Dock and FInder prefs tweaked and customized on the image. (They all live in /System?Library/User Template/English.lproj/Library/Preferences...)
    The one preference I cant get to stick is the option to "Always SHow Extensions" It appears to not be located in the usual com.apple.finder
    Can you tell me where this preference lives?

    user/library/Preferences/com.apple.AddressBook.plist
    Hold down the Option key when selecting "Go" in the Finder's menu to see your Library folder.

  • Where to put jar files reachable for ejb:s?

    Hello!
    I have a ejb that use some jar files.
    But I can not figure out where to put the jar files that I use from my ejb in Weblogic 8.1.3.
    Until now I have extracted all jar files and put them inside my ejb with my own class files. But this seems odd.
    So please help me out here.
    Best regrads
    Fredrik

    Dear,
    You might have downloaded either tar.gz or zip file. when you extract this file you will find a jar file and also some demos nad docs(api+help). place the poifs api jar file in 'WEB-INF\lib" folder and restart the server.
    In general any api jar files for web applications should be placed in WEB-INF\lib folder then only they are accesible. If you extracted the jar, then place entire package structure in WEB-INF\classes directory
    Regards,
    Nishant Kulkarni
    Software Engineer
    Bangalore
    [email protected]

  • Where put fif files for icons in local test

    When i test my form on local (http://xserver:8889/etc...)
    where i put my gif fiel for the icons ??
    In application server work fine but local don't fine le icons?
    Thank's !

    Mike,
    best practice is to have icons stored and deployed in jar files. This way tehre is no difference between OracleAS and Developer Suite
    see: http://www.oracle.com/technology/products/forms/pdf/webicons.pdf
    Frank

  • Where do I put config files for a webapp (war file)?

    To my understanding a war file is supposed to be dropped in. It's isn't intended to be unzipped by the person installing the webapp. Inside my web app I have some xml files I access to get configuration information for how the servlet works. This xml file is intended to be edited by the sysadmin using the webapp. So, it's obvious I can't put my xml file inside my war file otherwise they'd have to unzip it to edit it. So my question is, where do I put it? What is the normal place to put stuff like this for a webapp?
    Example:
    I make a servlet (or jsp/custom tags) that generates an explorer-like directory tree. It reads the tree folders and files from an xml file. So one sysadmin might make a tree that looks like this:
    Fruit
    |-apples
    | |-Gala
    |-oranges
    |-pears
    another sysadmin might make a tree that looks like this:
    Bookstore
    |-Technical Books
    | |- JSP to go
    |-Children's Books
    |-Dr Seuss
    And these are defined in the xml file.
    It's driving me crazy because I want to make my webapp deployable in a war file. Since I have to unzip it right now, the war file is useless.
    Thanks,
    David

    I don't have the answer, but I understand your pain. I was trying to figure this out last year before my company went out of business and made this problem go away.
    The issue is that you want to have a user install your webapp by deploying the war file and configure the app without unzipping the war file. If you can start the webapp first, why not just put the default or empty configuration file somewhere in your webapp director structure and write an administration servlet or JSP to configure it.
    If you must configure the application before it can start up, the following might apply.
    The obvious approach would be to install a properties or xml file separately from the war file and let the user edit that file. The problem is that your servlets and jsps need to be able to find it at run time. This is problematic because the current directory for relative paths seems to vary from one server to another. If I remember correctly, on Windows NT running Tomcat, current directory points to C:\jakarta-tomcat-x.x.x\bin. When running Websphere, it points to C:\WINNT. You can figure this out for the server your user is going to be running and have them put the file in one of those places. But I don't like putting my application files in places like that.
    I can't remember at the moment how it works in other servers, but at least in Tomcat you might put the configuration file in the webapps directory with your war file. Then you could have your servlet do a getServletContext().getRealPath() or something like that and back up the path one level to get to the file.
    At one point I thought it would be nice to put the path to the configuration file in the system environment, but we couldn't find any way in Java to get access to it.
    Will.

Maybe you are looking for

  • Finding the Class of a JavaCompiler's compiled code

    I'm using the new javax.tools.JavaCompiler to make an equation interpreter, but i'm running across some issues. I've got a test program set up: package test; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; import javax.tools.Simpl

  • VC Installation with IIS 6.0 and MS SQL 2005 on MSServer2003

    Dear all, Is it possible, if we plan to install VC6.0 with IIS6.0 and MS SQL 2005 on MS Server 2003? Now I have installation guide for install VC6.0 but it 's recommend to use MS SQL 2000 [Now MS SQL 2000 is very old and my company plan to use 2005]

  • Palm Desktop 4.1.4

    I am trying to move my Palm software to another computer (running Windows XP) for use with my M500, but when I try to download Palm Desktop 4.1.4 from the Palm website, I get the error message that the software is corrupt.  Does anyone know where I c

  • 9.0.2 to 9.0.2.6 Upgrade - Repository Upgrade

    Hi, I am unable to do the Repository Upgrade for the 9026 Portal Upgrade. I have successfully done all the pre-requisite patchset upgrades as well as the actual 9026 Portal upgrade. But when I run the upgrade.pl, I get an error. Here are the steps: E

  • Sharing photos through email

    I run Windows XP and use msn for email.  I have Photoshop Elements 7 and when I try to share photos my computer defaults to verizon e-mail.  How can I change this so that I can use my contact list I have in my msn account?