# File contains a path separator

**URL:** https://discourse.processing.org/t/file-contains-a-path-separator/6865
**Category:** Processing for Android
**Created:** [December 24, 2018, 3:35am UTC](https://discourse.processing.org/t/file-contains-a-path-separator/6865 "2018-12-24T03:35:50Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![FurryNightShade](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@FurryNightShade](https://discourse.processing.org/u/FurryNightShade)
#### Post date: [December 27, 2018, 2:58pm UTC](https://discourse.processing.org/t/file-contains-a-path-separator/6865/10 "2018-12-27T14:58:34Z")

</div>

Well, I don’t know, how I did it, but the folowing code works:

```auto
import processing.sound.*;

String filePath = "/sdcard/Sketchbook/VisualizerProject/data/song.mp3";

void setup(){
  stealFile(filePath, "song.mp3");
  SoundFile sf = new SoundFile(this, /*dataPath("song.mp3")*/filePath);
  sf.play();
}

void draw(){
  background(0);
}

boolean stealFile(String from, String filename){
  println("Stealing file \"" + from + "\"...");
  if(!(new File(from).exists())){
    println(" Fail: Input path invalid...");
    return false;
  }
  BufferedReader reader;
  PrintWriter writer;
  try{reader = createReader(from);}
  catch(Exception e){
    println(" Fail: Reader couldn't be created...");
    e.printStackTrace();
    return false;
  }
  try{writer = createWriter(dataPath(filename));}
  catch(Exception e){
    println(" Fail: Writer couldn't be created...");
    e.printStackTrace();
    return false;
  }
  
  while(true){
    String l;
    try{l = reader.readLine();}
    catch(Exception e){continue;}
    if(l == null) break;
    writer.println(l);
  }
  
  try{
    reader.close();
  }
  catch(Exception e){
    println("Reader couldn't be closed");
  }
  writer.flush();
  writer.close();
  
  println(" Success: File \"" + from + "\" succesfilly stolen and copied as \"" + filename + "\"."); 
  return true;
}

```

---

_[View the full topic](https://discourse.processing.org/t/file-contains-a-path-separator/6865)._
