का उपयोग कर जब मैं एक मुद्दा यह काम करने के लिए हो रही हो रही है से इनकार किया है। यह एक स्ट्रिंग में होता है जिसमें कई प्रकार के सूचनाएं शामिल होती हैं। हालांकि, जब मैं आदेश समय के साथ कार्यक्रम में परिवर्तन ट्रैक में एक फाइल करने के लिए स्ट्रिंग लिखने की कोशिश, मैं प्राप्त एक पहुँच त्रुटि से इनकार किया है:पहुँच FileOutputStream
void writeToFile(String input) throws Exception{
File file = new File("C:\\WeatherExports\\export.txt");
if(!file.exists()){
file.createNewFile();
}
BufferedWriter inFile = new BufferedWriter(new FileWriter(file,true));
try{
inFile.append(input);
inFile.newLine();
} catch(Exception e){
e.printStackTrace();
}
inFile.close();
}
स्टैकट्रेस yeilds:
java.io.FileNotFoundException: C:\WeatherExports\export.txt (Access is denied)
पूर्ण स्टैकट्रेस:
java.io.FileNotFoundException: C:\WeatherExports\export.txt (Access is denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at org.weatheralert.InfoManipMethods.writeToFile(InfoManipMethods.java:58)
at org.weatheralert.Form.actionPerformed(Form.java:108)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
लाइन 58:
BufferedWriter inFile = new BufferedWriter(new FileWriter(file,true));
उपयोगकर्ता आप प्रोग्राम चला रहे है के रूप में बना सकते हैं और उस निर्देशिका के लिए फ़ाइलें लिखने की अनुमति है? –
यह मेरा खाता है जो मेरे कंप्यूटर पर एक व्यवस्थापक है। मेरे पास यूएसी कंप्यूटर पर और एक अन्य उपयोगकर्ता के लिए बंद है। –
मैं सफलतापूर्वक फ़ाइल अगर मैं निर्देशिका में शामिल न करें और सीधे डिस्क सी के अंदर फ़ाइल बना सकते हैं? क्या निर्देशिका बनाने और फ़ाइल लिखने के लिए आपके पास लेखन अनुमतियां हैं? –