Java Code Examples for java.beans.XMLEncoder#flush()

The following examples show how to use java.beans.XMLEncoder#flush() . 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: WebServicePersistenceManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void saveDescriptor(WebServiceDescriptor descriptor) throws IOException {
    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(descriptor.getXmlDescriptor())));
    encoder.setExceptionListener(this);
    DefaultPersistenceDelegate delegate = new WebServiceDataPersistenceDelegate();
    encoder.setPersistenceDelegate(WSService.class, delegate);
    encoder.writeObject(descriptor);

    encoder.flush();
    encoder.close();
}
 
Example 2
Source File: ReadOnlyURLMapper.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {

    Runnable runnable = new Runnable() {
        public void run() {
            Collection<? extends AndroidJavaPlatformProvider8> providers = Lookup.getDefault().lookupAll(AndroidJavaPlatformProvider8.class);
            List<String> tmp = new ArrayList<>();
            for (AndroidJavaPlatformProvider8 provider : providers) {
                if (provider != null) {
                    JavaPlatform[] installedPlatforms = provider.getInstalledPlatforms();
                    for (JavaPlatform installedPlatform : installedPlatforms) {
                        List<ClassPath.Entry> entries = installedPlatform.getSourceFolders().entries();
                        for (ClassPath.Entry entrie : entries) {
                            if (!tmp.contains(entrie.getURL().getPath())) {
                                tmp.add(entrie.getURL().getPath());
                            }
                        }
                    }
                }
            }
            try {
                XMLEncoder encoder = new XMLEncoder(new FileOutputStream(LASTPLATFORMS_FILE));
                encoder.writeObject(tmp.toArray(new String[tmp.size()]));
                encoder.flush();
                encoder.close();
            } catch (Exception ex) {
            }
            reference.set(tmp.toArray(new String[tmp.size()]));
        }
    };
    POOL.execute(runnable);
}
 
Example 3
Source File: GradebookArchive.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Serializes this gradebook archive into an xml document
 */
public String archive() {
    if(log.isDebugEnabled()) log.debug("GradebookArchive.archive() called");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(baos));
    encoder.writeObject(this);
    encoder.flush();
    String xml = baos.toString();
    if(log.isDebugEnabled()) log.debug("GradebookArchive.archive() finished");
    return xml;
}
 
Example 4
Source File: GradebookArchive.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Serializes this gradebook archive into an xml document
 */
public String archive() {
    if(log.isDebugEnabled()) log.debug("GradebookArchive.archive() called");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(baos));
    encoder.writeObject(this);
    encoder.flush();
    String xml = baos.toString();
    if(log.isDebugEnabled()) log.debug("GradebookArchive.archive() finished");
    return xml;
}