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: Need help with program please: getting symbol error

Threaded View

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need help with program please: getting symbol error

    I have an assignment in my intro level programming class to write a program to count the number of times a character occurs in a file. My professor showed us how to write this program in class but I continue to get a missing symbol error on my FileInputStream line. Could someone please tell me how to fix this? Ignore my awful formatting in the program and realize that this is how my professor wants us to write this program. So try to keep it in this mindset. Appreciate the help! Here is my program as of now.
    import java.util.*;
     
    public class Prog7
    {
      public static void main(String[] args)
    {
      Scanner keybd = new Scanner(System.in);
     
    String filename;
    char ch;
    int count;
     
    //Prompt the user for filename.
     
    filename = keybd.next();
     
    count = frequency(ch,filename);
     
    System.out.println("In the file " + filename + ", the character " + ch + " appears " + count + " times.");
    }
     
    //Given a character ch and a filename.
    //Prints the number of times the character appears
    //in the file. Returns the count.
     
     
    public static int frequency(char ch, String fname)
    {
    FileInputStream f = new FileInputStream(newFile(fname));
     
    int count;
    char nextChar;
     
    count=0;
    nextChar=f.read();
     
    while(nextChar != -1)
    {if(nextChar==ch)
      count++;
     
      nextChar=f.read();
    }
    f.close();
     
    return count;
    }
    }
    Last edited by blinkzz; November 17th, 2009 at 09:27 PM.


Similar Threads

  1. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM
  2. cannot find symbol variable radius?
    By noobish in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 4th, 2009, 10:29 AM
  3. Error of data types and type casting in java program
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: September 2nd, 2009, 10:22 AM
  4. Error while creating Gym member database through Java programming
    By parvez07 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 26th, 2009, 02:17 AM
  5. Redirect error and output stream using java program
    By leenabora in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: June 16th, 2009, 04:12 AM