当前位置: 首页>>代码示例>>Java>>正文


Java FileObject.getOutputStream方法代码示例

本文整理汇总了Java中org.openide.filesystems.FileObject.getOutputStream方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getOutputStream方法的具体用法?Java FileObject.getOutputStream怎么用?Java FileObject.getOutputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.FileObject的用法示例。


在下文中一共展示了FileObject.getOutputStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateFromTemplateEncodingProperty

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testCreateFromTemplateEncodingProperty() throws Exception {
    FileObject root = FileUtil.createMemoryFileSystem().getRoot();
    FileObject fo = FileUtil.createData(root, "simpleObject.txt");
    OutputStream os = fo.getOutputStream();
    os.write("${encoding}".getBytes());
    os.close();
    assertEquals("content/unknown", fo.getMIMEType());
    fo.setAttribute ("template", Boolean.TRUE);
    assertEquals("content/unknown", fo.getMIMEType());
    fo.setAttribute("javax.script.ScriptEngine", "freemarker");
    assertEquals("text/x-freemarker", fo.getMIMEType());
    
    DataObject obj = DataObject.find(fo);
    DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
    
    Map<String,String> parameters = Collections.emptyMap();
    DataObject inst = obj.createFromTemplate(folder, "complex", parameters);
    FileObject instFO = inst.getPrimaryFile();
    
    Charset targetEnc = FileEncodingQuery.getEncoding(instFO);
    assertNotNull("Template encoding is null", targetEnc);
    assertEquals("Encoding in template doesn't match", targetEnc.name(), instFO.asText());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ScriptingCreateFromTemplateTest.java

示例2: generateConfig

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void generateConfig(FileObject prjDir, String cfgFilePath, EditableProperties propsToWrite) throws IOException {
    
    if (propsToWrite == null) {
        // do not create anything if props is null
        return;
    }
    FileObject jwsConfigFO = FileUtil.createData(prjDir, cfgFilePath);
    Properties props = new Properties();
    InputStream is = jwsConfigFO.getInputStream();
    props.load(is);
    is.close();
    if (props.equals(propsToWrite)) {
        // file already exists and props are the same
        return;
    }
    OutputStream os = jwsConfigFO.getOutputStream();
    propsToWrite.store(os);
    os.close();
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:J2SEProjectConfigurations.java

示例3: copy

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void copy(final String res, final FileObject data) throws Exception {
    final InputStream is = getClass ().getResourceAsStream ("data/"+res);   //NOI18N
    try {
        assertNotNull (res+" should exist", is);    //NOI18N
        FileLock lock = data.lock();
        try {
            OutputStream os = data.getOutputStream (lock);
            try {
                FileUtil.copy (is, os);
            } finally {
                os.close ();
            }
        } finally {
            lock.releaseLock ();
        }
    } finally {
        is.close ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:EncodingTest.java

示例4: dump

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JavaSourceUtilImplTest.java

示例5: testCreateLayerEntryWithoutLocalizingBundle

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** @see "#64273" */
public void testCreateLayerEntryWithoutLocalizingBundle() throws Exception {
    NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module");
    project.getProjectDirectory().getFileObject("src/org/example/module/resources/Bundle.properties").delete();
    FileObject mf = project.getProjectDirectory().getFileObject("manifest.mf");
    EditableManifest m;
    InputStream is = mf.getInputStream();
    try {
        m = new EditableManifest(is);
    } finally {
        is.close();
    }
    m.removeAttribute("OpenIDE-Module-Localizing-Bundle", null);
    OutputStream os = mf.getOutputStream();
    try {
        m.write(os);
    } finally {
        os.close();
    }
    CreatedModifiedFiles cmf = new CreatedModifiedFiles(project);
    Operation op = cmf.createLayerEntry("f", null, null, "F!", null);
    cmf.add(op);
    cmf.run();
    String[] supposedContent = new String[] {
        "<filesystem>",
        "<file name=\"f\"/>",
        "</filesystem>"
    };
    assertLayerContent(supposedContent, 
            new File(getWorkDir(), "module/src/org/example/module/resources/layer.xml"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:CreatedModifiedFilesTest.java

示例6: writeSchemaElement

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Writes the contents of <code>schemaElement</code> to the existing
 * <code>dbschemaFile</code>.
 */
private static void writeSchemaElement(SchemaElement schemaElement, FileObject dbschemaFile) throws IOException {
    FileLock lock = dbschemaFile.lock();
    try {
        OutputStream os = new BufferedOutputStream(dbschemaFile.getOutputStream(lock));
        try {
            schemaElement.save(os);
        } finally {
            os.close();
        }
    } finally {
        lock.releaseLock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DBSchemaManager.java

示例7: write

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Writes the content of the file.
 *
 * @param file file whose content should be written.
 * @param content new content of the file.
 * @throws IOException when the writing fails.
 */
private static void write(FileObject file, String content, String encoding) throws IOException {
    FileLock lock = file.lock();
    try {
        OutputStream os = file.getOutputStream(lock);
        os.write(content.getBytes(encoding));
        os.close();
    } finally {
        lock.releaseLock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MasterDetailGenerator.java

示例8: testPropertyEvaluationChanges

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@RandomlyFails
public void testPropertyEvaluationChanges() throws Exception {
    FreeformProject simple2 = copyProject(simple);
    PropertyEvaluator eval = simple2.evaluator();
    assertEquals("right src.dir", "src", eval.getProperty("src.dir"));
    EditableProperties p = new EditableProperties();
    FileObject buildProperties = simple2.getProjectDirectory().getFileObject("build.properties");
    assertNotNull("have build.properties", buildProperties);
    InputStream is = buildProperties.getInputStream();
    try {
        p.load(is);
    } finally {
        is.close();
    }
    assertEquals("right original value", "src", p.getProperty("src.dir"));
    p.setProperty("src.dir", "somethingnew");
    TestPCL l = new TestPCL();
    eval.addPropertyChangeListener(l);
    final OutputStream os = buildProperties.getOutputStream();
    try {
        p.store(os);
    } finally {
        // close file under ProjectManager.readAccess so that events are fired synchronously
        ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<Void>() {
            public Void run() throws Exception {
                os.close();
                return null;
            }
        });
    }
    assertEquals("got a change from properties file in src.dir", Collections.singleton("src.dir"), l.changed);
    l.reset();
    assertEquals("new value of src.dir", "somethingnew", eval.getProperty("src.dir"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:FreeformEvaluatorTest.java

示例9: testSnapshotEmbedding166592

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testSnapshotEmbedding166592 () throws IOException {
    clearWorkDir ();
    FileObject workDir = FileUtil.toFileObject (getWorkDir ());
    FileObject testFile = FileUtil.createData (workDir, "bla");
    OutputStream outputStream = testFile.getOutputStream ();
    OutputStreamWriter writer = new OutputStreamWriter (outputStream);
    writer.append ("Toto je testovaci file, na kterem se budou delat hnusne pokusy!!!");
    writer.close ();
    Source source = Source.create (testFile);
    Snapshot originalSnapshot = source.createSnapshot ();
    Embedding languageJednaEmbedding = Embedding.create (Arrays.asList (new Embedding[] {
        originalSnapshot.create (18, 4, "text/jedna"),
        originalSnapshot.create (33, 15, "text/jedna"),
    }));
    assertEquals ("text/jedna", languageJednaEmbedding.getMimeType ());
    Snapshot languageJednaSnapshot = languageJednaEmbedding.getSnapshot ();
    assertEquals ("text/jedna", languageJednaSnapshot.getMimeType ());
    assertEquals ("file se budou delat", languageJednaSnapshot.getText ().toString ());
    assertEquals (18, languageJednaSnapshot.getOriginalOffset (0));
    assertEquals (21, languageJednaSnapshot.getOriginalOffset (3));
    assertEquals (33, languageJednaSnapshot.getOriginalOffset (4));
    assertEquals (43, languageJednaSnapshot.getOriginalOffset (14));
    assertEquals (48, languageJednaSnapshot.getOriginalOffset (19));
    assertEquals (-1, languageJednaSnapshot.getOriginalOffset (20));

    assertEquals (-1, languageJednaSnapshot.getEmbeddedOffset (0));
    assertEquals (-1, languageJednaSnapshot.getEmbeddedOffset (17));
    assertEquals (0, languageJednaSnapshot.getEmbeddedOffset (18));
    assertEquals (3, languageJednaSnapshot.getEmbeddedOffset (21));
    assertEquals (4, languageJednaSnapshot.getEmbeddedOffset (22));
    assertEquals (-1, languageJednaSnapshot.getEmbeddedOffset (23));
    assertEquals (-1, languageJednaSnapshot.getEmbeddedOffset (32));
    assertEquals (4, languageJednaSnapshot.getEmbeddedOffset (33));
    assertEquals (5, languageJednaSnapshot.getEmbeddedOffset (34));
    assertEquals (-1, languageJednaSnapshot.getEmbeddedOffset (32));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:SnapshotTest.java

示例10: copyStringToFileObject

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static final FileObject copyStringToFileObject(FileObject fo, String content) throws IOException {
    OutputStream os = fo.getOutputStream();
    try {
        InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
        FileUtil.copy(is, os);
        return fo;
    } finally {
        os.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TestUtilities.java

示例11: copyStringToFileObject

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static final FileObject copyStringToFileObject(FileObject fo, String content) 
    throws IOException 
 {
    OutputStream os = fo.getOutputStream();
    try {
        InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
        FileUtil.copy(is, os);
        return fo;
    } finally {
        os.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:TestUtilities.java

示例12: testUnusualInstanceFileExtensions

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testUnusualInstanceFileExtensions() throws Exception {
    MockServices.setServices(ENV.class);
    FileObject inst = make("Shortcuts/C-F11.xml");
    OutputStream os = inst.getOutputStream();
    os.write("<action/>".getBytes());
    os.close();
    assertMapping(new NbKeymap(), KeyStroke.getKeyStroke(KeyEvent.VK_F11, KeyEvent.CTRL_MASK), inst, "whatever");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:NbKeymapTest.java

示例13: testChangedFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testChangedFile() throws IOException {
    File f = new File(dataRootDir, "workdir/root-test-versioned");
    FileObject fo = FileUtil.toFileObject(f);
    fo = fo.createData("deleteme.txt");
    File file = FileUtil.toFile(fo);
    OutputStream os = fo.getOutputStream();
    os.close();
    assertTrue(inteceptor.getBeforeCreateFiles().contains(file));
    assertTrue(inteceptor.getDoCreateFiles().contains(file));
    assertTrue(inteceptor.getCreatedFiles().contains(file));
    assertTrue(inteceptor.getBeforeChangeFiles().contains(file));
    assertTrue(inteceptor.getAfterChangeFiles().contains(file));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:VCSInterceptorTest.java

示例14: initModule

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void initModule() throws IOException {
    FileObject fo = modulesfolder.createData("com-jcraft-jsch.xml");
    File mod = new File(new File(ud, "modules"), "com-jcraft-jsch.jar");
    final HashMap<String, String> man = new HashMap<String, String>();
    man.put("Bundle-SymbolicName", "com.jcraft.jsch");
    createJar(mod, new HashMap<String, String>(), man);
    
    InputStream is = ModuleListStartLevelTest.class.getResourceAsStream("ModuleList-com-jcraft-jsch.xml");
    assertNotNull("Module definition found", is);
    final OutputStream os = fo.getOutputStream();
    FileUtil.copy(is, os);
    os.close();
    is.close();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ModuleListStartLevelTest.java

示例15: copyStringToFileObject

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static final FileObject copyStringToFileObject(FileObject fo, String content) throws IOException {
    OutputStream os = fo.getOutputStream();
    try {
        InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
        try {
            FileUtil.copy(is, os);
            return fo;
        } finally {
            is.close();
        }
    } finally {
        os.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CslTestBase.java


注:本文中的org.openide.filesystems.FileObject.getOutputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。