Results 1 to 6 of 6

Thread: JAVA project university related

  1. #1
    Join Date
    May 2011
    Location
    In an Island.
    Posts
    1,413
    Mentioned
    2 Post(s)
    Quoted
    149 Post(s)

    Default JAVA project university related

    Hello, so I need to do a project for university and I'm having doubts doing some stuff. I still haven't started like I should, and I only have 2 weeks left.
    I have those modifiers and selectors methods, but I can't find a way to use them, since I'm reading a text file to obtain information.
    I don't know how to use those methods, when we are obtaining information from a text file, and when the user is writing it directly through the console.
    Yes, I do need help, and I was hopping someone could add me to help me out with this.

    sincerely, Aquilino
    ''If you want something you've never had, you have to do something you've never done''


    total leve 2715/1b exp +... exterminated.

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    I don't completly understand your question. Might be a combination of rusty java and bad english from me though .

    Did you meant accessor methods instead of selectors? And mutator methods instead of modifiers?(these are often called the same). I googled selectors but that is an object for tracking read/write events in one thread. Sounds strange to use in the same sentence as modifiers methods.

    Tbh I don't understand what the program does at all. "Obtaining information from a text file" " writing through the console"

    Could you add more information?
    Working on: Tithe Farmer

  3. #3
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Yes we need more information or code examples. Right now it makes no sense to me either.

    Script source code available here: Github

  4. #4
    Join Date
    Oct 2011
    Location
    Chicago
    Posts
    3,352
    Mentioned
    21 Post(s)
    Quoted
    437 Post(s)

    Default

    Do you mean likeee if the user types something in, the program records the information into a variable?
    If thats the case you can do it very very easily, and even have constructors through the means of empty variables.

    For example
    Int a = 0;

    Scanner keyboard = new Scanner (System.in);
    System.out.println("Type your favorite number");
    a = keyboard.nextInt;

    System.out.println("Your favorite number is" + a );

    I actually have no idea what you need help with so all this information is very generic.
    Try reading this code, its what I use almost every time I want to implement reading from a text file

    Code:
    import java.io.*;
    
    public class ReadFile {
    
        public static void main(String[] args){
            String string="";
            String file ="textFile.txt";
    
            //reading   
            try{
                InputStream ips=new FileInputStream(fichier); 
                InputStreamReader ipsr=new InputStreamReader(ips);
                BufferedReader br=new BufferedReader(ipsr);
                String line;
                while ((ligne=br.readLine())!=null){
                    System.out.println(line);
                    string+=line+"\n";
                }
                br.close(); 
            }       
            catch (Exception e){
                System.out.println(e.toString());
            }
    
            //writing
            try {
                FileWriter fw = new FileWriter (file);
                BufferedWriter bw = new BufferedWriter (fw);
                PrintWriter fileOut = new PrintWriter (bw); 
                    fileOut.println (string+"\n test of read and write !!"); 
                fileOut.close();
                System.out.println("the file " + file + " is created!"); 
            }
            catch (Exception e){
                System.out.println(e.toString());
            }       
        }
    }




    Anti-Leech Movement Prevent Leeching Spread the word
    Insanity 60 Days (Killer workout)
    XoL Blog (Workouts/RS/Misc)

  5. #5
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Me and onilika are working on it. Thanks for the help though xol
    Working on: Tithe Farmer

  6. #6
    Join Date
    Oct 2011
    Location
    Chicago
    Posts
    3,352
    Mentioned
    21 Post(s)
    Quoted
    437 Post(s)

    Default

    Oh ok sweet, good luck guys!




    Anti-Leech Movement Prevent Leeching Spread the word
    Insanity 60 Days (Killer workout)
    XoL Blog (Workouts/RS/Misc)

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •