While trying to write file in specified directory i am getting exception.
Java code :-
public void jsonToYaml(JSONObject json, String studioName)
throws JSONException, org.codehaus.jettison.json.JSONException,
IOException {
Yaml.dump(Yaml.dump(JsonToMap.jsonToMap(json)), new File("config.yml"));
BufferedReader br = new BufferedReader(new FileReader("config.yml"));
String line;
studioName = studioName.toLowerCase();
File writeFile = new File("sudo /var/iprotecs/idns2.0","" + studioName + ".yaml");
FileOutputStream fos = new FileOutputStream(writeFile);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
try {
while ((line = br.readLine()) != null) {
String line1 = line.replace("\"", "");
String line2 = line1.replaceAll("!java.util.HashMap", "");
String line3 = line2.replaceAll("---", "");
String line4 = line3.replace("|", "");
System.out.println(line4);
bw.write(line4);
bw.newLine();
}
} catch (FileNotFoundException e) {
System.out.println(e);
}
}
Exception :-
How to create file write content to it.
java.io.FileNotFoundException: sudo /var/iprotecs/idns2.0/asia.yaml (No such file or directory)
sudo" folder in your current folder.