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 2 of 2

Thread: Beginner Project

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Beginner Project

    So i am working on a java project for my first semester programming class and I have code here with an error I am stumped on.

    The user will input the file name containing equipment information from the terminal. The program will read from the file and put the lines into a tokenizer which will separate the tokens in accordance to commas.

    My current code:

    import java.util.*;
    import java.io.*;


    public class Project4
    {
    public static void main(String args[]) throws FileNotFoundException
    {

    String fix;


    Scanner in = new Scanner(System.in);

    System.out.println("Welcome to Transport Canada");
    System.out.print("Please enter text file: ");
    String filename = in.nextLine();

    File file = new File(filename);
    Scanner inp = new Scanner(file);

    fix = MTBF(inp);

    System.out.println(fix);
    inp.close();

    }
    public static String MTBF(String fixing)
    {
    StringTokenizer strTokenizer = new StringTokenizer(fixing, ",");
    while(strTokenizer.hasMoreTokens())
    {
    fixing = strTokenizer.nextToken();

    }
    return fixing;
    }
    }


    The input file looks like this:

    Secondary,456,3:2011,1,1,4,1
    Primary,457,4:2011,2,0,2,2
    Backup,458,5:2011,10,11,4,3


    So where are my errors, what am I doing wrong and most importantly...HOW FIX!?
    Thank you for your time


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,795
    Thanks
    54
    Thanked 2,343 Times in 2,314 Posts

    Default Re: Beginner Project

    what am I doing wrong a
    Can you show what the problem is? Print out what you read and all of what you process that shows your problem.

Similar Threads

  1. Beginner
    By codejava in forum Member Introductions
    Replies: 2
    Last Post: August 22nd, 2011, 09:11 AM
  2. Beginner
    By angelo24 in forum Member Introductions
    Replies: 1
    Last Post: August 19th, 2011, 08:14 AM
  3. Beginner - Help with my code.
    By eddross in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2010, 10:30 AM
  4. I need a help ! i am beginner
    By yinky in forum Java Theory & Questions
    Replies: 3
    Last Post: September 30th, 2009, 08:22 AM
  5. Best beginners project in Java
    By Fendaril in forum Java Theory & Questions
    Replies: 3
    Last Post: February 10th, 2009, 08:52 AM