मैं अपने जावा कोड संकलित और चलाने के लिए ग्रहण का उपयोग कर रहा हूं।धागे "मुख्य" java.io.FileNotFoundException में अपवाद: त्रुटि
यहां मुझे त्रुटि मिल रही है।
Exception in thread "main" java.io.FileNotFoundException: file.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at helloworld.main(helloworld.java:9)
यहाँ मेरी कोड है
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class helloworld {
public static void main(String[] args) throws IOException {
Scanner KB = new Scanner(new File("file.txt"));
while (KB.hasNext()) {
String line = KB.nextLine();
System.out.println(line);
}
}
}
file.txt
मैं अपने प्रोजेक्ट में एक ही फ़ोल्डर में file.txt बनाया है।
क्या आपकी फ़ाइल सीधे आपके प्रोजेक्ट फ़ोल्डर के अंतर्गत है? –
यह एससीआर के तहत है, मैंने एक को बिन के नीचे भी रखा है, क्योंकि स्क्रै काम नहीं करता है। – Mowgli
'नई फ़ाइल ("file.txt") प्रिंट करने का प्रयास करें। मौजूद है()' क्या यह 'सत्य' उत्पन्न कर रहा है? यदि नहीं, तो 'नई फ़ाइल ("file.txt") प्रिंट करने का प्रयास करें। getAbsoluteFile()' क्या आप इसकी अपेक्षा करते हैं? – amit