File tempF = File.createTempFile("tmp", "");
String fileName = tempF.getCanonicalPath();
tempF.delete(); // we only needed the temp file name, so delete the file
PigFile f = new PigFile(fileName);
f.store(b, new FuncSpec(BinStorage.class.getCanonicalName()), pigServer.getPigContext());
pigServer.registerQuery("a = load '" + fileName + "' using BinStorage();");
pigServer.registerQuery("b = foreach a generate $0#'apple',flatten($1#'orange');");
Iterator<Tuple> iter = pigServer.openIterator("b");