Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to create file without succes - file appears elsewhere?
    primarykey
    data
    text
    <p>I tried to create 3 empty files in my home directory, using this:</p> <pre><code> this.mainpath = System.getenv("HOME"+"/"); this.single = new File(mainpath + "sin.r"); this.complete = new File (mainpath + "com.r"); this.ward = new File (mainpath+"w.r"); </code></pre> <p>I was unter the impression that this would give me the files desired. However, if I search my home directory, or any other directory, for this files, none of them exists. What am I doing wrong?</p> <p>Edit: I just find out: I do get a file, but not in my home directory, but the path to it would be /home/myname/NetBeansProjects/myorojectname/nullsin.r.</p> <p>However, I specifically wanted to create the file in my home!</p> <p>Well, my code now reads:</p> <pre><code>this.mainpath = System.getenv("user.home"); this.mainpath = this.mainpath + "/"; this.single = new File(mainpath + "sin.r"); this.single.createNewFile(); System.out.println(this.single.getAbsolutePath()); this.complete = new File (mainpath + "comp.r"); this.complete.createNewFile(); this.ward = new File (mainpath+"w.r"); this.ward.createNewFile(); </code></pre> <p>The "success" of this, however, is that I get an IOException at the first createNeWFile(): File not found.</p> <p>as for my code how I tried to write sth into those file, there it is:</p> <pre><code> FileWriter writer1 = null; FileWriter writer2 = null; FileWriter writer3 = null; try { writer1 = new FileWriter(single); writer2 = new FileWriter(complete); writer3 = new FileWriter(ward); writer1.write("x = cbind(1,2,3)"); writer2.write("x = cbind(1,2,3)"); writer3.write("x = cbind(1,2,3)"); writer1.flush(); writer2.flush(); writer3.flush(); } catch (IOException ex) { System.out.println(ex.getStackTrace()); } finally { try { writer1.close(); writer2.close(); writer3.close(); } catch (IOException ex) { System.out.println(ex.getStackTrace()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload