Homework help please..

I'm doing a homework assignment for school where i need to make a program that will ask user for filename, open the file and display the first 5 lines.. I have the text over and over again.. I'm just a little confused about this.. Even if i take a code out of the book and put into netbeans and try runing it i am getting the same error message. Is their something im missing.. I make a file in notepad that im trying to open and its not working.
ERROR MESSAGE
run:
Enter the filename you want to open FileToBeOpened
Exception in thread "main" java.io.FileNotFoundException: FileToBeOpened (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.util.Scanner.<init>(Scanner.java:621)
at filereader.filereader.main(filereader.java:29)
Java Result: 1
This is the beginning of my program
package filereader;
import java.util.Scanner;
import java.io.*;
* @author jessica
public class filereader {
     * @param args the command line arguments
    public static void main(String[] args)  throws IOException
        int MaxLines;
        //create a Scanner object for keyboard input.
        Scanner keyboard = new Scanner(System.in);
        //Get the filename.
        System.out.print("Enter the filename you want to open");
        String filename = keyboard.nextLine();
        //open the file
        File file = new File(filename);
        Scanner inputFile = new Scanner(file);

your file name entered is not correct in that Java is not looking for your file where you think it's looking. To find out where Java is looking, write a small program that simply calls:
public class Fu1
  public static void main(String[] args)
    System.out.println(System.getProperty("user.dir"));
}and you will know where Java is starting to look.
Or you could just type in the full path and file name.

Similar Messages

  • Accounting homework help

    Can’t do Accounting Homework?
    Email me your accounting homework & accounting assignments & I will send you back the solutions. In addition to Accounting homework help & accounting assignments help, I also help in online accounting exams, online accounting tests & tutoring, accounting word problems, accounting case study & accounting essays.
    Send me your accounting & finance assignments and i will send you back the answers. I also help in projects, papers and essays.
    I also help in:-
    (a) accounting homework help
    (b) finance homework help
    (c) managerial accounting assignment solutions
    (d) net present value, future value & compounding
    (e) bonds, stocks, options, derivatives homework
    (f) financial management homework help
    (g) statistics homework help
    (h) homework ratio analysis & cash flow statement homework
    (i) income statement & balance sheet & shares & debentures
    (j) marginal costing, standard costing & variable costing
    (k) marketing homework help
    (l) economics homework help
    (m) accounting-finance homework
    (n) activity based costing , break even point & cap analysis
    (o) LIFO, FIFO, weighted average & journal entries homework & trial balance
    please visit once http://www.theaccountinghomework.com
    or email me on the [email protected]

    Whenever It comes to my mind the word Accounting, I get really sick & weak to my kneels. It happens a lot. Once I came across www.accountinhomeworktutor.com
    The guys are really helpful in accounting homework help & finance assignment help for financial comparative analysis, case study analysis, ratio analysis.
    I recommend this to everyone out there.
    finance homework help

  • ACCOUNTINGHOMEWORKTUTORcom, for finance homework help, Accounting Homework

    Email me your accounting homework & accounting assignments & I will send you back the solutions. In addition to Accounting homework help & accounting assignments help, I also help in online accounting exams, online accounting tests & tutoring, accounting word problems, accounting case study & accounting essays.
    Send me your accounting & finance assignments and i will send you back the answers. I also help in projects, papers and essays.
    I also help in:-
    (a) accounting homework help
    (b) finance homework help
    (c) managerial accounting assignment solutions
    (d) net present value, future value & compounding
    (e) bonds, stocks, options, derivatives homework
    (f) financial management homework help
    (g) statistics homework help
    (h) homework ratio analysis & cash flow statement homework
    (i) income statement & balance sheet & shares & debentures
    (j) marginal costing, standard costing & variable costing
    (k) marketing homework help
    (l) economics homework help
    (m) accounting-finance homework
    (n) activity based costing , break even point & cvp analysis
    (o) lifo, fifo, weighted average & journal entries homework & trial balance
    please visit once http://www.AccountingHomeworkTutor.com
    or email me on [email protected]

    Whenever It comes to my mind the word Accounting, I get really sick & weak to my kneels. It happens a lot. Once I came across www.accountinhomeworktutor.com
    The guys are really helpful in accounting homework help & finance assignment help for financial comparative analysis, case study analysis, ratio analysis.
    I recommend this to everyone out there.
    finance homework help

  • Homework Help...I bet you guys are sick of this...

    OK....This problem has been on here before, and I know you are probably really sick of seeing it...sorry. Anyway, here it is... It's just an invoice program with an invoicetest to test the first's capabilities. I was doing pretty well (i thought) but have now hit a brick wall. The first part (invoice.java) goes as follows, and compiles just fine.
    //Invoice.java to represent an invoice for an item sold in a store
    public class Invoice
    private String partNumber;
    private String partDesc;
    private int partQuantity;
    private double partPrice;
    // constructor
    public Invoice( String number, String desc, int quantity, double price )
    partNumber = number;
    partDesc = desc;
    partQuantity = quantity;
    partPrice = price;
    if (partQuantity < 0 )
    partQuantity = 0;
    if (partPrice < 0 )
    partPrice = 0.0;
    // method to set the part number
    public void setPartNumber( String number )
    partNumber = number;
    // method to set the part description
    public void setPartDesc( String desc )
    partDesc = desc;
    //method to set the part quantity
    public void setPartQuantity( int quantity )
    partQuantity = quantity;
    // method to set the part price
    public void setPartPrice( double price )
    partPrice = price;
    // method to retrieve the part number
    public String getPartNumber()
    return partNumber;
    // method to retrieve the part description
    public String getPartDesc()
    return partDesc;
    // method to retrieve the part quantity
    public int getPartQuantity()
    return partQuantity;
    // method to retrieve the part price
    public double getPartPrice()
    return partPrice;
    // method to calculate the invoice amount
    private double amount;
    public double getInvoiceAmount()
    amount = partQuantity * partPrice;
    return amount;
    So, we move on to the second part (invoicetest.java) which goes as follows.
    //InvoiceTest.java to test Invoice.java
    import java.util.Scanner;
    public class InvoiceTest
    public static void main( String args [] )
    // create a Invoice object
    Invoice myInvoice = new Invoice();
    // create Scanner to obtain input
    Scanner input = new Scanner( System.in );
    String pNumber;
    String pDesc;
    int pQuantity;
    double pPrice;
    System.out.print( "Enter the part number: " );
    pNumber = input.nextLine();
    myInvoice.setPartNumber( pNumber );
    System.out.println();
    System.out.print( "Enter the part description: " );
    pDesc = input.nextLine();
    myInvoice.setPartDesc( pDesc );
    System.out.println();
    System.out.print( "Enter the part quantity: " );
    pQuantity = input.nextInt();
    myInvoice.setPartQuantity( pQuantity );
    System.out.println();
    System.out.print( "Enter the part price: " );
    pPrice = input.nextDouble();
    myInvoice.setPartPrice( pPrice );
    System.out.println();
    // display part information
    System.out.printf( "Part number: %s\n",
    myInvoice.getPartNumber() );
    System.out.printf( "Part description: %s\n",
    myInvoice.getPartDesc() );
    System.out.printf( "Part quantity: %d\n",
    myInvoice.getPartQuantity() );
    System.out.printf( "Part price: $%.2f\n",
    myInvoice.getPartPrice() );
    System.out.printf( "Invoice amount: $%.2f\n",
    myInvoice.getInvoiceAmount() );
    and i get this error message: (yes, ^ should be under "new"
    InvoiceTest.java:10: cannot find symbol
    symbol : constructor Invoice()
    location: class Invoice
    Invoice myInvoice = new Invoice();
    ^
    I know you all hate doing other people's homework, because it really doesn't help the person. But, I really have given this a try, and I'm running out of time. Any help would be greatly appreciated!

    Ok, one more question...this one is probably pretty simple. This is the employee.java program (i wrote the employeetest.java) program also, but it's useless unless I can get this figured out. It'll probably be really simple for all you studs out there, but I've scoured this thing and can't figure out where I'm missing a brace or where I have an extra one...someone help PLEASE.
    public class Employee
         // Constructor
         public Employee ( String fname, String lname, double monthlySalary )
              firstName = fname;     // initialize firstName
              lastName = lname;     // initialize lastName
              if ( monthlySalary != 0.0 )
                   monthlySalary = salary; // initialize monthlySalary
         public void setFirstName( String fname )
              firstName = fname;
         public void setLastName( String lname )
              lastName = lname;
         public void setMonthlySalary( double salary )
              monthlySalary = salary;
         public String getFirstName()
               return firstName;
         public String getLastName()
               return lastName;
         public double getMonthlySalary()
               return monthlySalary;
         }it says { expected in last line...oh, i know this is silly, but i just seem hopeless!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I keep being asked to update my Safari but when I do a Software update it scans but never gives me a list and just says no new updates. Help please!

    I keep being asked to update my Safari but when I do a Software update it scans but never gives me a list and just says no new updates. Help please!

    There are no updates to either OS 10.5.8 or Safari 5.0.6.
    If you need a later version of Safari you must first upgrade your operating system to a later version of OS X.

  • At the end of my IMovie I want to write some text: as in" Happy Birthday Mandy we had a great time with you. etc..  How do I go about this? Which icon in IMovie lets me have a place to write text?? help please

    Please see my ? above: Im making an IMovie and need the last frame to just be text (can be on a color). I don't know how to go about doing this.  Ive already done all my photos and captions. Need to have it ready for TOMORROW: Friday May 23rd. Help please!
    Thanks

    You can choose a background for the text from Maps and Backgrounds.  Just drag a background to the end of the timeline, adjust to desired duration then drag title above it.
    Geoff.

  • I have just updated my PC with version11.14. I can no longer connect to my Bose 30 soundtouch via media player Can anyone help please

    I have a Bose soundtouch system .Until today I could play my iTunes music through it via air  player . .I have just uploaded the latest upgrade from iTunes and now I am unable to connect to the Bose system . Can anyone help please? I can connect via my iPad and by using the Bose app so it is not the Bose at fault

    @puebloryan, I realize this thread is a bit old, but I have encountered a similr problem and wondered if you had found a solution. I've been using home sharing from itines on my PCs for years, but two days ago, it suddenly stopped. I can share from my Macs, but not from the ONE PC library where I keep all my tunes. I tried all the usual trouble-shooting measures.
    After turning home sharing off on the PC's iTunes, turning it back on and turning some other settings off and on, my Macs and Apple TV could briefly "see" the PC library, but as soon as I try to connect -- the wheel spins for a bit and then the connection vanishes. It's as if they try and then give up.
    Since this sounds so similar to your problem, I was hoping you finally found a solution. I am also starting a new thread. Thanks!

  • My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?

    My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?
    Thank. Simon

    Brian - The batteries are fine and there has only every been one keyboard paired with it. We have tried my MacPro keyboard as well, and it will not even recognise that there is a discoverable keyboard nearby.
    Thanks, Simon

  • Photoshop Elements 6 on Mac help please !!!!!

    Hi there,
              I need help please !!!!!
    I have PSE 6 for my imac and bought myself a NIKON D60 so far so good. I have installed PSE 6 which comes with ADOBE Bridge CS3
    I have bought a book as well as I am new to photoshop and in fact DSLR cameras.
    I have got my photos into Bridge OK by the way they are JPEG format. According to the book I can open the JPEG in camera RAW by either selecting the JPEG and then pressing cmd+R or by selecting the JPEG and select open with and camera RAW should be available to selct.
    I cannot get of the options to work any ideas please
    Secondly I have taken some photos in RAW format and put then into Bridge again I cannot get the camera RAW interface to open with these neff images.
    If I try to open the image PSE 6 opens and gives me an error that the file format is not supported by PSE 6
    Am I missing something here as I have been trying for a week now !!!!!
    Sorry if this comes across a stupid question but it is new to me
    Chris      UK

    There's no "theory" about it. You should be able to open a raw file from bridge by double-clicking it, but it will open in ACR in PSE. You can't just use ACR within bridge in PSE, if that's what you're trying to do. To open a JPEG in ACR, go to file>Open in PSE and choose Camera raw as the format after you select the file but before you click Open.
    If you've correctly updated ACR, bridge should show you thumbnails of your raw files. If it doesn't try emptying the Bridge cache.

  • Photoshop CS2. Help please.

    Approx 8 years ago I purchased Photoshop CS2 online from Adobe. This past weekend I had to buy a new computer (Windows 8.1), and when I logged into my Adobe account just now to obtain my serial number and enter it after I attempted to download CS2, it said invalid serial number. Help please.
    Both tech support and the online chat person were not able to help me.

    The Activation Servers for CS2 and prior have been taken down. See the link below for an explanation and solution. Be sure to follow all directions, including using the new download serial number supplied on the page.
    CS2 and prior
    http://helpx.adobe.com/x-productkb/policy-pricing/creative-suite-2-activation-end-life.htm l
    --OB

  • I  used to have an OLD Photoshop cd but it has been lost and my program is no longer on cd. I talked with some photographer friends and this is what one of them told me to get: Adobe Photoshop Lightroom and CS CC... HELP please?

    I  used to have an OLD Photoshop cd but it has been lost and my program is no longer on cd. I talked with some photographer friends and this is what one of them told me to get: Adobe Photoshop Lightroom and CS CC... HELP please?

    If you still have your serial number, look at OLDER previous versions http://www.adobe.com/downloads/other-downloads.html
    Otherwise, the US$ 9.99 plan is what is current at Cloud Plans https://creative.adobe.com/plans

  • Creative live cam voice help please

    Help please,
    We are using the "live cam voice" model, with our computer (Vista 32bit), that appears to work OK, but after a few minutes we get the BSOD! We have tried un installing and re-installing drivers without any effect.Has anyone had this problem and if so how did you fix it.
    Regards,
    Arthur

    Thanks for your response. I have tried 3 ports so far, all with the same outcome. One of my sons had it happen to him on another computer (XP SP2) using this webcam . As to programmes open at the same time, I am not computer literate and have no idea what programmes were running on each occasion.We use the webcam for Skype and apart from that I may also have IE open and perhaps Outlook Express. Over and above those CS4 sometimes.
    If I cannot resolve this, can any one suggest another webcam please.
    Regards,
    Arthur

  • I get error message "unknown error" When trying to log on to itunes via pc, help please!

    I get error message "unknown error" When trying to log on to itunes via pc, help please!

    Hello, trolle56.
    Thank you for the question.  You may find these articles helpful in troubleshooting the error received with the iTunes Store. 
    Can't connect to the iTunes Store
    http://support.apple.com/kb/ts1368
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/ts3297
    Cheers,
    Jason H. 

  • I downloaded an upgrade to my adobe reader today, and ever since my search engine has switched to yahoo and wont change back to google. I have a macbook pro, help please? Does anyone know how I can change this back? I have tried through my settings but it

    I downloaded an upgrade to my adobe reader today, and ever since my search engine has switched to yahoo and wont change back to google. I have a macbook pro, help please? Does anyone know how I can change this back? I have tried through my settings but it doesnt work

    Hi Timia,
    If you are using Safari as a web browser :-
    Open Safari, go to Safari menu > Preferences > General, and put Google as the homepage. Then, choose Google as your default search engine.
    If you are using Google Chrome as the web browser :-
      Open Google Chrome.
      In the top right corner of the page, click the Chrome menu Chrome menu > Settings.
      In the "Search" section, select Google from the drop-down menu.
    Let me know if you still experience any issue.
    Regards,
    Aadesh

  • Will My Purchased Songs On My iPod Be affected if i sync my itunes library to my iPod?Help Please!

    A Song that i purchased on my iPod Wasnt able to get into my itunes library somehow ,and i want to sync my itunes library to my iPod because i recently Got a store brought CD and i want to insert it ,but im afraid my songs will get deleted ,especially my purchased ones...can someone help please ?

    Just sync. You can alway redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

Maybe you are looking for