Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Reading files and writing files

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Reading files and writing files

    I as of right now have no code. I'm just stuck on the problem and don't know how to start. I'm a beginner programmer so don't expect too much from me.

    The assignment can be found here: http://www.cas.mcmaster.ca/~khedri/w...ssignment4.pdf

    If someone can just guide me that would be greatly appreciated. It's not a difficult task for some of you, but it is for me.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Reading files and writing files

    You will want to post all relevant material here in the forum rather than as a link. This might mean that you have to put in the effort to type in a bit of text, but it is well worth it if we are to better understand your problem. Next you will want to tell us exactly where you're stuck and what confuses you. Very vague questions, such as "I don't know where to start" often lead to recommendations to read or re-read the tutorials. So if you can give as as good a description of your specific problems, we can likely give you better and more helpful answers.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Reading files and writing files

    At the bottom of the assignment, it tells me to use these method signatures. Not sure what they do, but I just copied and pasted it into my new class file. I started by writing the code for opening the file and the try/catch exception handling. But other then that I'm completely confused on how to read the file for the 3rd field.

    --- Update ---

    public class RecordReader {
    	public static String[] readThirdFieldsFromFile(String inputFileName) throws FileNotFoundException, IOException{
     
    		Scanner newScanner = newScanner(System.in);
     
    		try{
    			System.out.print("Enter the name of a file you wish to open: ");
    			String fileName = newScanner.nextLine();
    			newScanner = newScanner(new File(fileName));
    		}
    		catch (exception FileNotFoundException){
    			System.out.println ("FileNotFoundException");
    		}
     
    	}
    }

    So far the only thing I have

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Reading files and writing files

    Again, consider typing in your assignment instructions here. Many (myself included) will avoid clicking on links, or are unable to due to firewall restrictions.

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Reading files and writing files

    So many nice people
    !

  6. #6
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Reading files and writing files

    Okay the file didn't show up as good as i thought it would. Give me another minute
    Attached Images Attached Images

Similar Threads

  1. Reading and writing files in a JApplet
    By Majora94 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: February 21st, 2012, 01:53 PM
  2. FileWrite Over-Writing txt Files. D:
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 8th, 2012, 04:31 PM
  3. Reading In Then Writing Out Massive Files
    By aussiemcgr in forum Java Theory & Questions
    Replies: 3
    Last Post: July 28th, 2011, 07:00 PM
  4. Writing to files
    By nitwit3 in forum Java Theory & Questions
    Replies: 3
    Last Post: July 25th, 2011, 04:00 AM
  5. Reading and Writing Text Files
    By kappasig84 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 1st, 2010, 07:16 PM