org.openide.filesystems.FileLock Java Examples

The following examples show how to use org.openide.filesystems.FileLock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebBuildScriptExtensionProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void removeJaxWsExtension(final AntBuildExtender ext) throws IOException {
    AntBuildExtender.Extension extension = ext.getExtension(JAXWS_EXTENSION);
    if (extension != null) {
        ProjectManager.mutex().writeAccess(new Runnable() {
            @Override
            public void run() {
                ext.removeExtension(JAXWS_EXTENSION);
            }
        });
        ProjectManager.getDefault().saveProject(project);
    }
    FileObject jaxws_build = project.getProjectDirectory().getFileObject(TransformerUtils.JAXWS_BUILD_XML_PATH);
    if (jaxws_build != null) {
        FileLock fileLock = jaxws_build.lock();
        if (fileLock!=null) {
            try {
                jaxws_build.delete(fileLock);
            } finally {
                fileLock.releaseLock();
            }
        }
    }
}
 
Example #2
Source File: FileUtil.java    From jeddict with Apache License 2.0 6 votes vote down vote up
public static void copyStaticResource(String inputTemplatePath, FileObject toDir, String targetFolder, ProgressHandler handler) throws IOException {
    InputStream stream = loadResource(inputTemplatePath);
    try (ZipInputStream inputStream = new ZipInputStream(stream)) {
        ZipEntry entry;
        while ((entry = inputStream.getNextEntry()) != null) {
            if (entry.getName().lastIndexOf('.') == -1) { //skip if not file
                continue;
            }
            String targetPath = isBlank(targetFolder) ? entry.getName() : targetFolder + '/' + entry.getName();
            if (handler != null) {
                handler.progress(targetPath);
            }
            FileObject target = org.openide.filesystems.FileUtil.createData(toDir, targetPath);
            FileLock lock = target.lock();
            try (OutputStream outputStream = target.getOutputStream(lock)) {
                for (int c = inputStream.read(); c != -1; c = inputStream.read()) {
                    outputStream.write(c);
                }
                inputStream.closeEntry();
            } finally {
                lock.releaseLock();
            }
        }
    }
}
 
Example #3
Source File: JFXProjectProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void run() throws Exception {
    OutputStream os = null;
    FileLock lock = null;
    try {
        lock = projPropsFO.lock();
        os = projPropsFO.getOutputStream(lock);
        ep.store(os);
    } finally {
        if (lock != null) {
            lock.releaseLock();
        }
        if (os != null) {
            os.close();
        }
    }
    return null;
}
 
Example #4
Source File: FileUtil.java    From jeddict with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    try {
        FileObject xml = org.openide.filesystems.FileUtil.createData(toDir, toFile);
        String content = readResource(loadResource(fromFile));
        if (content != null) {
            FileLock lock = xml.lock();
            try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(xml.getOutputStream(lock)))) {
                bw.write(content);
            } finally {
                lock.releaseLock();
            }
        }
        result = xml;
    } catch (IOException e) {
        exception = e;
    }
}
 
Example #5
Source File: AbstractSourceFileObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public final boolean delete() {
    if (isDirty() != null) {
        //If the file is modified in editor do not delete it
        return false;
    } else {
        final FileObject file = handle.resolveFileObject(false);
        if (file == null) {
            return false;
        }
        try {
            FileLock lock = file.lock();
            try {
                file.delete (lock);
                return true;
            }
            finally {
                lock.releaseLock();
            }
        } catch (IOException e) {
            return false;
        }
    }
}
 
Example #6
Source File: JavaSourceUtilImplTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void dump(
        final FileObject wd,
        final Map<String,byte[]> clzs) throws IOException {
    for (Map.Entry<String,byte[]> clz : clzs.entrySet()) {
        final String extName = FileObjects.convertPackage2Folder(clz.getKey());
        final FileObject data = FileUtil.createData(wd, String.format(
                "%s.class", //NOI18N
                extName));
        FileLock l = data.lock();
        try (final OutputStream out = data.getOutputStream(l)) {
            out.write(clz.getValue());
        }finally {
            l.releaseLock();
        }
    }
    System.out.printf("Dumped into: %s%n", FileUtil.getFileDisplayName(wd));
}
 
Example #7
Source File: DDHelper.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void run() {
    try {
        // PENDING : should be easier to define in layer and copy related FileObject (doesn't require systemClassLoader)
        if (toDir.getFileObject(toFile) != null) {
            return; // #229533, #189768: The file already exists in the file system --> Simply do nothing
        }
        FileObject xml = FileUtil.createData(toDir, toFile);
        String content = readResource(DDHelper.class.getResourceAsStream(fromFile));
        if (content != null) {
            FileLock lock = xml.lock();
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(xml.getOutputStream(lock)));
            try {
                bw.write(content);
            } finally {
                bw.close();
                lock.releaseLock();
            }
        }
        result = xml;
    }
    catch (IOException e) {
        exception = e;
    }
}
 
Example #8
Source File: WebServiceManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void rmDir(File dir) {
    if (dir == null) {
        return;
    }

    FileObject fo = FileUtil.toFileObject(dir);
    if (fo != null) {
        FileLock lock = null;
        try {
            lock = fo.lock();
            fo.delete(lock);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            if (lock != null) {
                lock.releaseLock();
            }
        }
    }
}
 
Example #9
Source File: CrashingAPTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void setUp() throws Exception {
    clearWorkDir();
    File workDir = getWorkDir();
    File cacheFolder = new File (workDir, "cache"); //NOI18N
    cacheFolder.mkdirs();
    IndexUtil.setCacheFolder(cacheFolder);
    FileObject wd = FileUtil.toFileObject(this.getWorkDir());
    assertNotNull(wd);
    this.src = wd.createFolder("src");
    this.data = src.createData("Test","java");
    FileLock lock = data.lock();
    try {
        PrintWriter out = new PrintWriter ( new OutputStreamWriter (data.getOutputStream(lock)));
        try {
            out.println ("public class Test {}");
        } finally {
            out.close ();
        }
    } finally {
        lock.releaseLock();
    }
    ClassPathProviderImpl.getDefault().setClassPaths(TestUtil.getBootClassPath(),
                                                     ClassPathSupport.createClassPath(new URL[0]),
                                                     ClassPathSupport.createClassPath(new FileObject[]{this.src}),
                                                     ClassPathSupport.createClassPath(System.getProperty("java.class.path")));
}
 
Example #10
Source File: CopyOnSave.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void copySrcToDest( FileObject srcFile, FileObject destFile) throws IOException {
    if (destFile != null && !srcFile.isFolder()) {
        InputStream is = null;
        OutputStream os = null;
        FileLock fl = null;
        try {
            is = srcFile.getInputStream();
            fl = destFile.lock();
            os = destFile.getOutputStream(fl);
            FileUtil.copy(is, os);
        } finally {
            if (is != null) {
                is.close();
            }
            if (os != null) {
                os.close();
            }
            if (fl != null) {
                fl.releaseLock();
            }
        }
    }
}
 
Example #11
Source File: SerialDataConvertor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** try to perform atomic action */
private void try2run() throws IOException {
    FileLock lock;
    OutputStream los;
    synchronized (READWRITE_LOCK) {
        if (XMLSettingsSupport.err.isLoggable(Level.FINER)) {
            XMLSettingsSupport.err.finer("saving " + getDataObject()); // NOI18N
        }
        lock = getScheduledRequest().getFileLock();
        if (lock == null) return;
        los = file.getOutputStream(lock);

        OutputStream os = new BufferedOutputStream(los, 1024);
        try {
            buf.writeTo(os);
            if (XMLSettingsSupport.err.isLoggable(Level.FINER)) {
                XMLSettingsSupport.err.finer("saved " + dobj); // NOI18N
            }
        } finally {
            os.close();
        }
    }
}
 
Example #12
Source File: SaasClientPhpAuthenticationGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void replaceTokens(FileObject fO, Map<String, String> tokens) throws IOException {
    FileLock lock = fO.lock();
    try {
        BufferedReader reader = new BufferedReader(new FileReader(FileUtil.toFile(fO)));
        String line;
        StringBuffer sb = new StringBuffer();
        while ((line = reader.readLine()) != null) {
            for(Map.Entry e:tokens.entrySet()) {
                String key = (String) e.getKey();
                String value = (String) e.getValue();
                line = line.replaceAll(key, value);
            }
            sb.append(line+"\n");
        }
        OutputStreamWriter writer = new OutputStreamWriter(fO.getOutputStream(lock), "UTF-8");
        try {
            writer.write(sb.toString());
        } finally {
            writer.close();
        }
    } finally {
        lock.releaseLock();
    }
}
 
Example #13
Source File: AssetDataObject.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Savable loadAsset() {
    if (isModified() && savable != null) {
        return savable;
    }
    ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
    if (mgr == null) {
        DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("File is not part of a project!\nCannot load without ProjectAssetManager."));
        return null;
    }
    FileLock lock = null;
    try {
        lock = getPrimaryFile().lock();
        Savable spatial = (Savable) mgr.loadAsset(getAssetKey());
        savable = spatial;
        lock.releaseLock();
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    } finally {
        if (lock != null) {
            lock.releaseLock();
        }
    }
    return savable;
}
 
Example #14
Source File: LanguagesDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void copyAndSubstituteTokens(final URL content,
        final FileLock lock, final FileObject targetFO, final Map<String,String> tokens) throws IOException {
    OutputStream os = targetFO.getOutputStream(lock);
    try {
        PrintWriter pw = new PrintWriter(os);
        try {
            InputStream is = content.openStream();
            try {
                Reader r = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(r);
                String line;
                while ((line = br.readLine()) != null) {
                    pw.println(tokens == null ? line : replaceTokens(tokens, line));
                }
            } finally {
                is.close();
            }
        } finally {
            pw.close();
        }
    } finally {
        os.close();
    }
}
 
Example #15
Source File: SampleWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void unZipFile(InputStream source, FileObject rootFolder) throws IOException {
    try {
        ZipInputStream str = new ZipInputStream(source);
        ZipEntry entry;
        while ((entry = str.getNextEntry()) != null) {
            if (entry.isDirectory()) {
                FileUtil.createFolder(rootFolder, entry.getName());
                continue;
            }
            FileObject fo = FileUtil.createData(rootFolder, entry.getName());
            FileLock lock = fo.lock();
            try {
                OutputStream out = fo.getOutputStream(lock);
                try {
                    FileUtil.copy(str, out);
                } finally {
                    out.close();
                }
            } finally {
                lock.releaseLock();
            }
        }
    } finally {
        source.close();
    }
}
 
Example #16
Source File: ArtifactCopyOnSaveSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void copy(FileObject sourceFile, FileObject destFile) throws IOException {
    InputStream is = null;
    OutputStream os = null;
    FileLock fl = null;
    try {
        is = sourceFile.getInputStream();
        fl = destFile.lock();
        os = destFile.getOutputStream(fl);
        FileUtil.copy(is, os);
    } finally {
        if (is != null) {
            is.close();
        }
        if (os != null) {
            os.close();
        }
        if (fl != null) {
            fl.releaseLock();
        }
    }
}
 
Example #17
Source File: J2SEActionProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NonNull
private FileObject getCosScript() throws IOException {
    final FileObject snippets = FileUtil.createFolder(
            Places.getCacheSubdirectory(SNIPPETS));
    FileObject cosScript = snippets.getFileObject(SCRIPT);
    if (cosScript == null) {
        cosScript = FileUtil.createData(snippets, SCRIPT);
        final FileLock lock = cosScript.lock();
        try (InputStream in = getClass().getResourceAsStream(SCRIPT_TEMPLATE);
                OutputStream out = cosScript.getOutputStream(lock)) {
            FileUtil.copy(in, out);
        } finally {
            lock.releaseLock();
        }
    }
    return cosScript;
}
 
Example #18
Source File: FolderObjTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testMoveWithAttributes() throws Exception {
    final FileObject workDirFo = FileBasedFileSystem.getFileObject(getWorkDir());
    FileObject target = workDirFo.createFolder("target");
    FileObject folder = workDirFo.createFolder("a");
    folder.createData("non.empty");
    folder.setAttribute("name", "jmeno");
    assertEquals("jmeno", folder.getAttribute("name"));
    FileLock lock = folder.lock();
    FileObject newF = folder.move(lock, target, "b", null);
    assertFalse("Invalidated", folder.isValid());
    lock.releaseLock();
    assertEquals("Name is not b", "b", newF.getNameExt());
    WeakReference<?> ref = new WeakReference<FileObject>(newF);
    newF = null;
    assertGC("Folder can disappear", ref);
    folder = target.getFileObject("b");
    assertNotNull("Folder b found", folder);
    assertEquals("The attribute remains even after rename", "jmeno", folder.getAttribute("name"));
    assertEquals("One children", 1, folder.getChildren().length);
}
 
Example #19
Source File: FolderObjTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testMove85336() throws Exception {
    final FileObject workDirFo = FileBasedFileSystem.getFileObject(getWorkDir());
    FolderObj to =  (FolderObj)FileUtil.createFolder(workDirFo, "a/b/c");
    FolderObj from =  (FolderObj)FileUtil.createFolder(workDirFo, "aa/b/c");        
    assertNotNull(to);
    assertNotNull(from);
    BaseFileObj what =  (BaseFileObj)FileUtil.createData(from, "hello.txt");        
    assertNotNull(what);
    FileLock lck = what.lock();
    ProvidedExtensions.IOHandler io = new ProvidedExtensionsTest.ProvidedExtensionsImpl().
            getMoveHandler(what.getFileName().getFile(), new File(to.getFileName().getFile(),what.getNameExt())); 
    to.getChildren();
    try {
        what.move(lck, to, what.getName(), what.getExt(), io);
    } finally {
        lck.releaseLock();
    }        
}
 
Example #20
Source File: AppClientProjectGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new application manifest file with minimal initial contents.
 * @param dir the directory to create it in
 * @param path the relative path of the file
 * @throws IOException in case of problems
 */
private static void createManifest(FileObject dir, String path) throws IOException {
    if (dir.getFileObject(path) == null) {
        FileObject manifest = FileUtil.createData(dir, path);
        FileLock lock = manifest.lock();
        try {
            OutputStream os = manifest.getOutputStream(lock);
            try {
                PrintWriter pw = new PrintWriter(os);
                pw.println("Manifest-Version: 1.0"); // NOI18N
                pw.println("X-COMMENT: Main-Class will be added automatically by build"); // NOI18N
                pw.println(); // safest to end in \n\n due to JRE parsing bug
                pw.flush();
            } finally {
                os.close();
            }
        } finally {
            lock.releaseLock();
        }
    }
}
 
Example #21
Source File: ProjectJAXWSClientSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** folder where xml client artifacts should be saved, e.g. WEB-INF/wsdl/client/SampleClient
 */
protected FileObject getWsdlFolderForClient(String name) throws IOException {
    FileObject globalWsdlFolder = getWsdlFolder(true);
    FileObject oldWsdlFolder = globalWsdlFolder.getFileObject("client/"+name); //NOI18N
    if (oldWsdlFolder!=null) {
        FileLock lock = oldWsdlFolder.lock();
        try {
            oldWsdlFolder.delete(lock);
        } finally {
            lock.releaseLock();
        }
    }
    FileObject clientWsdlFolder = globalWsdlFolder.getFileObject("client"); //NOI18N
    if (clientWsdlFolder==null) clientWsdlFolder = globalWsdlFolder.createFolder("client"); //NOI18N
    return clientWsdlFolder.createFolder(name);
}
 
Example #22
Source File: URLDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Stores a specified URL into the file backing up this URL object.
 *
 * @param  newUrlString  URL to be stored in the file
 */
void setURLString(String newUrlString) {
    FileObject urlFile = getPrimaryFile();
    if (!urlFile.isValid()) {
        return;
    }
    FileLock lock = null;
    try {
        lock = urlFile.lock();
        OutputStream os = urlFile.getOutputStream(lock);
        os.write(newUrlString.getBytes());
        os.close();
    } catch (IOException ioe) {
        ErrorManager.getDefault().notify(ErrorManager.WARNING, ioe);
    } finally {
        if (lock != null) {
            lock.releaseLock();
        }
    }
}
 
Example #23
Source File: PersistenceManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Deletes specified file object */
public static void deleteOneFO (FileObject fo) {
    FileLock lock = null;
    if (fo.isValid()) {
        try {
            lock = fo.lock();
            fo.delete(lock);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            if (lock != null) {
                lock.releaseLock();
            }
        }
    }
}
 
Example #24
Source File: ArchiveTimeStamps.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    final Store store = getAndSetPropertiesToSave(null);
    if (store != null) {
        try {
            LOG.fine("STORING");             //NOI18N
            final FileObject file = getArchiveTimeStampsFile(true);
            final FileLock lock = file.lock();
            try {
                final OutputStream out = new BufferedOutputStream(file.getOutputStream(lock));
                try {
                    store.store(out);
                } finally {
                    out.close();
                }
            } finally {
                lock.releaseLock();
            }
            LOG.fine("STORED");             //NOI18N
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
}
 
Example #25
Source File: JDKSetupTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 
 * Creates Ant build script with a target that calls JavaScript
 * @return FileObject of the created build script file
 */
public FileObject createAntTestScript() throws IOException {
    String dir = this.getWorkDirPath();
    assertNotNull(dir);
    File dirF = new File(dir);
    if(!dirF.exists()) {
        dirF.mkdirs();
    }
    assertTrue(dirF.exists());
    FileObject dirFO = FileUtil.toFileObject(dirF);
    FileObject buildFile = dirFO.createData(BUILD_SCRIPT_FILE);
    FileLock lock = buildFile.lock();
    try {
        OutputStream os = buildFile.getOutputStream(lock);
        PrintWriter writer = new PrintWriter(os);
        writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        writer.println("<project name=\"TestJavaScript\" default=\"testjs\" basedir=\".\">");
        writer.println("    <description>");
        writer.println("        Ant build script to test presence of JavaScript engine");
        writer.println("    </description>");
        writer.println("    <target name=\"testjs\">");
        writer.println("        <script language=\"javascript\">");
        writer.println("            <![CDATA[");
        writer.println("                println(\"" + JS_MESSAGE + "\");");
        writer.println("            ]]>");
        writer.println("        </script>");
        writer.println("    </target>");
        writer.println("</project>");
        writer.flush();
        writer.close();
        os.close();
    } finally {
        lock.releaseLock();
    }
    return buildFile;
}
 
Example #26
Source File: FileObjectAccessor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Clears the file and sets the offset to 0 */
public void resetFile() throws IOException {
    FileObject folder = fo.getParent();
    String name = fo.getName();
    String ext  = fo.getExt();
    FileLock lock = fo.lock();
    try {
        fo.delete(lock);
    } finally {
        lock.releaseLock();
    }
    fo = folder.createData(name, ext);
    actOff = 0;
}
 
Example #27
Source File: DataObjectFactoryProcessorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private FileObject createXmlFile(String content, String ext) throws Exception {
    FileObject file = FileUtil.createMemoryFileSystem().getRoot().createData("file" + ext);
    FileLock lock = file.lock();
    try {
        OutputStream out = file.getOutputStream(lock);
        try {
            out.write(content.getBytes());
        } finally {
            out.close();
        }
    } finally {
        lock.releaseLock();
    }
    return file;
}
 
Example #28
Source File: SourceUtilsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static FileObject createFile (final FileObject folder, final String name, final String content) throws IOException {
    final FileObject fo = FileUtil.createData(folder, name);
    final FileLock lock = fo.lock();
    try {
        final OutputStream out = fo.getOutputStream(lock);
        try {
            FileUtil.copy(new ByteArrayInputStream(content.getBytes()), out);
        } finally {
            out.close();
        }
    } finally {
        lock.releaseLock();
    }
    return fo;
}
 
Example #29
Source File: AssetsLookupProvider.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Lookup createAdditionalLookup(Lookup lookup) {
    Project prj = lookup.lookup(Project.class);
    project = prj;
    FileObject assetsProperties = prj.getProjectDirectory().getFileObject("nbproject/assets.properties");
    if (assetsProperties == null) {
        assetsProperties = prj.getProjectDirectory().getFileObject("nbproject/project.properties");
    } else {
        Logger.getLogger(AssetsLookupProvider.class.getName()).log(Level.WARNING, "Project is using old assets.properties file");
    }
    if (assetsProperties != null && assetsProperties.isValid()) {
        FileLock lock = null;
        try {
            lock = assetsProperties.lock();
            InputStream in = assetsProperties.getInputStream();
            Properties properties = new Properties();
            properties.load(in);
            in.close();
            String assetsFolderName = properties.getProperty("assets.folder.name", "assets");
            if (prj.getProjectDirectory().getFileObject(assetsFolderName) != null) {
                Logger.getLogger(AssetsLookupProvider.class.getName()).log(Level.INFO, "Valid jMP project, extending with ProjectAssetManager");
                return Lookups.fixed(new ProjectAssetManager(prj, assetsFolderName), openedHook);
            }
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            if (lock != null) {
                lock.releaseLock();
            }
        }
    }

    return Lookups.fixed();
}
 
Example #30
Source File: DataEditorSupportTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public java.io.OutputStream getOutputStream (FileLock lock) throws IOException {
    if (openStreams != 0) {
        IOException e = new IOException("There is stream already, cannot write down!");
        if (previousStream != null) {
            e.initCause(previousStream);
        }
        throw e;
    }
    class ContentStream extends java.io.ByteArrayOutputStream {
        public ContentStream() {
            openStreams = -1;
        }
        @Override
        public void close () throws java.io.IOException {
            if (openStreams != -1) {
                IOException ex = new IOException("One output stream");
                ex.initCause(previousStream);
                throw ex;
            }
            //assertEquals("One output stream", -1, openStreams);
            openStreams = 0;
            previousStream = new Exception("Closed");
            super.close ();
            RUNNING.content = new String (toByteArray ());
        }
    }
    previousStream = new Exception("Output");
    return new ContentStream ();
}