List of usage examples for org.eclipse.jdt.internal.core.builder JavaBuilder writeState
public static void writeState(Object state, DataOutputStream out) throws IOException
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
/** * Saves the built state for the project. *//*from w ww . ja va2s .c om*/ private void saveBuiltState(PerProjectInfo info) throws CoreException { if (JavaBuilder.DEBUG) System.out.println(Messages.bind(Messages.build_saveStateProgress, info.project.getName())); File file = getSerializationFile(info.project); if (file == null) return; long t = System.currentTimeMillis(); try { DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); try { out.writeUTF(JavaCore.PLUGIN_ID); out.writeUTF("STATE"); //$NON-NLS-1$ if (info.savedState == null) { out.writeBoolean(false); } else { out.writeBoolean(true); JavaBuilder.writeState(info.savedState, out); } } finally { out.close(); } } catch (RuntimeException e) { try { file.delete(); } catch (SecurityException se) { // could not delete file: cannot do much more } throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Messages.bind(Messages.build_cannotSaveState, info.project.getName()), e)); } catch (IOException e) { try { file.delete(); } catch (SecurityException se) { // could not delete file: cannot do much more } throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Messages.bind(Messages.build_cannotSaveState, info.project.getName()), e)); } if (JavaBuilder.DEBUG) { t = System.currentTimeMillis() - t; System.out.println(Messages.bind(Messages.build_saveStateComplete, String.valueOf(t))); } }
From source file:org.objectstyle.wolips.target.TargetBuilderPersistenceStore.java
License:Open Source License
protected void writeImportantState(File target) { try {//w ww .j a va2 s.c o m DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(target))); try { Set aSet = _buildStates.entrySet(); out.writeInt(aSet.size()); for (Iterator iter = aSet.iterator(); iter.hasNext();) { Map.Entry element = (Map.Entry) iter.next(); String key = (String) element.getKey(); State value = (State) element.getValue(); out.writeUTF(key); JavaBuilder.writeState(value, out); } } finally { out.close(); } } catch (Exception e) { System.out.println(e); } }