title: java.io.FileNotFoundException: (Read-only file system) Mac
body: <p>I have a SpringBoot app in which I am trying to test generation of barcodes but I am getting this error <code>java.io.FileNotFoundException:  (Read-only file system) Mac</code>.</p>
  
  <p>Here's the code to accomplish this task:</p>
  
  <p><code>pom.xml</code></p>
  
  <pre class="lang-xml prettyprint-override"><code>        &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.13&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sf.barcode4j&lt;/groupId&gt;
              &lt;artifactId&gt;barcode4j&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p><code>Test Class</code></p>
  
  <pre class="lang-java prettyprint-override"><code>public class FooTest extends TestCase {
      @Test
      public void testP() {
          try {
              Code128Bean bean = new Code128Bean();
              final int dpi = 160;
  
              //Configure the barcode generator
              bean.setModuleWidth(UnitConv.in2mm(2.8f / dpi));
  
              bean.doQuietZone(false);
  
              //Open output file
              File outputFile = new File("/" + "test" + ".JPG");
  
              FileOutputStream out = new FileOutputStream(outputFile);
  
              BitmapCanvasProvider canvas = new BitmapCanvasProvider(
                      out, "image/x-png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
  
              //Generate the barcode
              bean.generateBarcode(canvas, "test");
  
              //Signal end of generation
              canvas.finish();
  
              System.out.println("Bar Code is generated successfully…");
          }
          catch (IOException ex) {
              ex.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p><code>Error</code></p>
  
  <pre><code>java.io.FileNotFoundException: /test.JPG (Read-only file system)
      at java.io.FileOutputStream.open0(Native Method)
      at java.io.FileOutputStream.open(FileOutputStream.java:270)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:162)
  </code></pre>
  
  <p>Any ideas on how I could make this work on my machine (MacBook)? Would the configuration be different for Linux? </p>