當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLDecoder.close方法代碼示例

本文整理匯總了Java中java.beans.XMLDecoder.close方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLDecoder.close方法的具體用法?Java XMLDecoder.close怎麽用?Java XMLDecoder.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.beans.XMLDecoder的用法示例。


在下文中一共展示了XMLDecoder.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadAnObjectXML

import java.beans.XMLDecoder; //導入方法依賴的package包/類
public static Object loadAnObjectXML(String path) throws FileNotFoundException {
    try {
        XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(path)));
        Object obj = decoder.readObject();
        decoder.close();
        return obj;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        throw e;
    }
}
 
開發者ID:phweda,項目名稱:MFM,代碼行數:12,代碼來源:PersistUtils.java

示例2: objectXmlDecoder

import java.beans.XMLDecoder; //導入方法依賴的package包/類
/** 
 * 讀取由objSource指定的XML文件中的序列化保存的對象,返回的結果經過了List封裝 
 * @param objSource 帶全部文件路徑的文件全名 
 * @return 由XML文件裏麵保存的對象構成的List列表(可能是一個或者多個的序列化保存的對象)   
 * @throws FileNotFoundException 指定的對象讀取資源不存在 
 * @throws IOException 讀取發生錯誤 
 * @throws Exception 其他運行時異常發生 
 */ 
public static List objectXmlDecoder(String objSource)  
 throws FileNotFoundException,IOException,Exception 
{ 
 List objList = new ArrayList();     
 File fin = new File(objSource); 
 FileInputStream fis = new FileInputStream(fin); 
 XMLDecoder decoder = new XMLDecoder(fis); 
 Object obj = null; 
 try 
 { 
  while( (obj = decoder.readObject()) != null) 
  { 
   objList.add(obj); 
  } 
 } 
 catch (Exception e) 
 { 
  // TODO Auto-generated catch block     
 } 
 fis.close(); 
 decoder.close();      
 return objList; 
}
 
開發者ID:LuJiangLin,項目名稱:TestDemo1-github,代碼行數:32,代碼來源:ObjectToXMLUtil.java

示例3: test

import java.beans.XMLDecoder; //導入方法依賴的package包/類
static void test(AbstractTest object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    XMLEncoder encoder = new XMLEncoder(output);
    encoder.setPersistenceDelegate(
            object.getClass(),
            new DefaultPersistenceDelegate(new String[] {"value"}));

    encoder.writeObject(object);
    encoder.close();

    System.out.print(output);

    ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
    XMLDecoder decoder = new XMLDecoder(input);
    AbstractTest result = (AbstractTest) decoder.readObject();
    decoder.close();

    if (object.getValue() != result.getValue())
        throw new Error("Should be " + object);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:AbstractTest.java

示例4: test

import java.beans.XMLDecoder; //導入方法依賴的package包/類
/**
 * This is entry point to start testing.
 *
 * @param security  use {@code true} to start
 *                  second pass in secure context
 */
final void test(boolean security) {
    byte[] array = getFieldValue("XML").getBytes(); // NON-NLS: the field name
    ByteArrayInputStream input = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(input);
    decoder.setExceptionListener(this);
    validate(decoder);
    try {
        throw new Error("unexpected object" + decoder.readObject());
    } catch (ArrayIndexOutOfBoundsException exception) {
        // expected exception
    }
    decoder.close();
    if (security) {
        System.setSecurityManager(new SecurityManager());
        test(false);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:AbstractTest.java

示例5: openWorkspace

import java.beans.XMLDecoder; //導入方法依賴的package包/類
/**
 * Open a workspace file.
 * 
 * @param file
 *            the file.
 */
public void openWorkspace(File file) {

	repaintNow();
	setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
	closeAllFrames();
	try {
		FileInputStream fos = new FileInputStream(file);
		XMLDecoder decoder = new XMLDecoder(fos);
		config = (BrowserConfig) decoder.readObject();
		readMDIConfig(config.getMDIConfig());
		decoder.close();
		recentMenu.addRecentWorkspace(file);
		if (classpathBrowser != null) {
			classpathBrowser.setClasspathComponent(config);
		}
	} catch (FileNotFoundException e) {
		GUIHelper.showMessage(this, "An error occured while reading "
				+ file.getPath(), JOptionPane.ERROR_MESSAGE);
	} finally {
		setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}
	workspaceFile = file;
	updateTitle();
	actionSaveWorkspaceAs.setEnabled(true);
}
 
開發者ID:linchaolong,項目名稱:ApkToolPlus,代碼行數:32,代碼來源:BrowserMDIFrame.java

示例6: read

import java.beans.XMLDecoder; //導入方法依賴的package包/類
public static CheckList read(File file) throws Exception {
    XMLDecoder decoder = new XMLDecoder(new FileInputStream(file));
    try {
        return (CheckList) decoder.readObject();
    } finally {
        decoder.close();
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:9,代碼來源:CheckList.java

示例7: setText

import java.beans.XMLDecoder; //導入方法依賴的package包/類
@Override public void setText(String code) {
    ByteArrayInputStream stream = new ByteArrayInputStream(code.getBytes(StandardCharsets.UTF_8));
    XMLDecoder decoder = new XMLDecoder(stream);
    checklist = (CheckList) decoder.readObject();
    decoder.close();
    checkListView.setCheckListNode(new CheckListFormNode(checklist, Mode.EDIT));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:8,代碼來源:CheckListEditor.java

示例8: readObject

import java.beans.XMLDecoder; //導入方法依賴的package包/類
private Object readObject(byte[] array) {
    ByteArrayInputStream input = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(input);
    decoder.setExceptionListener(this);
    initialize(decoder);
    Object object = decoder.readObject();
    decoder.close();
    return object;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:AbstractTest.java

示例9: decode

import java.beans.XMLDecoder; //導入方法依賴的package包/類
private Object decode(byte[] array) {
    ByteArrayInputStream in = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(in, null, this, this);
    Object object = decoder.readObject();
    validate(object);
    decoder.close();
    return object;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:Test6329581.java

示例10: handleXml

import java.beans.XMLDecoder; //導入方法依賴的package包/類
public static Object handleXml(InputStream in) {
    XMLDecoder d = new XMLDecoder(in);
    try {
        Object result = d.readObject(); //Deserialization happen here
        return result;
    }
    finally {
        d.close();
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:11,代碼來源:XmlDecodeUtil.java

示例11: main

import java.beans.XMLDecoder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    StringBuilder sb = new StringBuilder(256);
    sb.append("file:");
    sb.append(System.getProperty("test.src", "."));
    sb.append(File.separatorChar);
    sb.append("test.jar");

    URL[] url = {new URL(sb.toString())};
    URLClassLoader cl = new URLClassLoader(url);

    Class type = cl.loadClass("test.Test");
    if (type == null) {
        throw new Error("could not find class test.Test");
    }


    InputStream stream = new ByteArrayInputStream(DATA.getBytes());

    ExceptionListener el = new ExceptionListener() {
        public void exceptionThrown(Exception exception) {
            throw new Error("unexpected exception", exception);
        }
    };

    XMLDecoder decoder = new XMLDecoder(stream, null, el, cl);
    Object object = decoder.readObject();
    decoder.close();

    if (!type.equals(object.getClass())) {
        throw new Error("unexpected " + object.getClass());
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:33,代碼來源:Test4676532.java

示例12: test

import java.beans.XMLDecoder; //導入方法依賴的package包/類
private static void test(Locale locale, byte[] data) {
    Locale.setDefault(locale);
    System.out.println("locale = " + locale);

    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));
    System.out.println("object = " + decoder.readObject());
    decoder.close();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:Test6341798.java

示例13: doLoad

import java.beans.XMLDecoder; //導入方法依賴的package包/類
@Override
public void
doLoad(
	InputStream 	in,
	Map				usersMap )
{
	XMLDecoder decoder = new XMLDecoder( in );
	UserManagerConfig managerConfig = (UserManagerConfig)decoder.readObject();
	for (Iterator iter = managerConfig.getUsers().iterator(); iter.hasNext();) {
		UserProfile user = (UserProfile) iter.next();
		usersMap.put(user.getUsername().toLowerCase(), user);
	}
	System.out.println("UserManager: registered " + usersMap.size() + " users");
	decoder.close();
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:16,代碼來源:UserManagerXMLPersist.java

示例14: dump

import java.beans.XMLDecoder; //導入方法依賴的package包/類
/** Display the data */
public void dump() throws IOException {
    XMLDecoder inp = new XMLDecoder(
            new FileInputStream(FILENAME));
    System.out.println(inp.readObject());
    inp.close();
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:8,代碼來源:SerialDemoXML.java

示例15: deSerizalize

import java.beans.XMLDecoder; //導入方法依賴的package包/類
public Object deSerizalize(String file) throws FileNotFoundException 
{
	XMLDecoder decoder = new XMLDecoder(new FileInputStream(file));
	Object obj = decoder.readObject();
	decoder.close();
	return obj;
	
}
 
開發者ID:shuqin,項目名稱:ALLIN,代碼行數:9,代碼來源:XMLSerialization.java


注:本文中的java.beans.XMLDecoder.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。