I have a some code to start learning about it with. But when I run the code I get this error:
Exception in thread "main" java.io.FileNotFoundException: rawData.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.jav a:106)
at java.util.Scanner.<init>(Scanner.java:621)
at readandwrite.Main.main(Main.java:26)
This is my code:
Expand|Select|Wrap|Line Numbers
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package readandwrite;
- /**
- *
- * @author Ned
- */
- import java.util.Scanner;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintStream;
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args)
- // TODO code application logic here
- throws FileNotFoundException {
- Scanner diskScanner = new Scanner(new File("rawData.txt"));
- PrintStream diskWriter = new PrintStream("cookedData.txt");
- double unitPrice, quantity, total;
- unitPrice = diskScanner.nextDouble();
- quantity = diskScanner.nextInt();
- total = unitPrice * quantity;
- diskWriter.println(total);
- }
- }