Hello guys. I started learning about how to read information from disks and things.
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.FileNot FoundException: rawData.txt (No such file or directory)
at java.io.FileInp utStream.open(N ative Method)
at java.io.FileInp utStream.<init> (FileInputStrea m.java:106)
at java.util.Scann er.<init>(Scann er.java:621)
at readandwrite.Ma in.main(Main.ja va:26)
This is my code:
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.FileNot FoundException: rawData.txt (No such file or directory)
at java.io.FileInp utStream.open(N ative Method)
at java.io.FileInp utStream.<init> (FileInputStrea m.java:106)
at java.util.Scann er.<init>(Scann er.java:621)
at readandwrite.Ma in.main(Main.ja va:26)
This is my code:
Code:
/*
* 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);
}
}
Comment