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


Java ObjectOutputStream.flush方法代码示例

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


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

示例1: main

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
    String fileStorageLocation = "torfiles";
    OnionProxyManager onionProxyManager = new JavaOnionProxyManager(
            new JavaOnionProxyContext(new File(fileStorageLocation)));

    int totalSecondsPerTorStartup = 4 * 60;
    int totalTriesPerTorStartup = 5;
    // Start the Tor Onion Proxy
    if (onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup) == false) {
        return;
    }
    // Start a hidden service listener
    int hiddenServicePort = 80;
    int localPort = onionProxyManager.getIPv4LocalHostSocksPort();
    String OnionAdress = "d2lz63pgzqms2xxp.onion";


    Socket clientSocket = Utilities.socks4aSocketConnection(OnionAdress, hiddenServicePort, "127.0.0.1", localPort);

    ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());
    out.flush();

    out.writeObject("helloooooooooooooooooooooooo frommmmmmm hereeeeeeeeeeeeeeeeeeeeeeeeeeee");
    out.flush();
}
 
开发者ID:PanagiotisDrakatos,项目名称:T0rlib4j,代码行数:26,代码来源:TorClientSocks4.java

示例2: testSerializationAndCloning

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private final void testSerializationAndCloning(Tree node) throws Exception {

		// Serialize
		ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		oos.writeObject(node);
		oos.flush();
		byte[] bytes = baos.toByteArray();
		// System.out.println(new String(bytes));

		// Deserialize
		ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
		ObjectInputStream ois = new ObjectInputStream(bais);
		Tree copy = (Tree) ois.readObject();

		String txtOriginal = node.toString("debug");
		String txtCopy = copy.toString("debug");

		assertEquals(txtOriginal, txtCopy);

		// Cloning
		txtCopy = node.clone().toString("debug");
		assertEquals(txtOriginal, txtCopy);
	}
 
开发者ID:berkesa,项目名称:datatree,代码行数:25,代码来源:TreeTest.java

示例3: Init

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
public void Init() throws IOException, InterruptedException {
    if(ctx==null){
        Log.e("TorTest", "Couldn't start Tor!");
        return;
    }
    String fileLocation = "torfiles";
    // Start the Tor Onion Proxy
    AndroidTorRelay node = new  AndroidTorRelay(ctx,fileLocation);
    int hiddenServicePort = 80;
    int localPort = node.getSocksPort();
    String OnionAdress = "xl5rbgygp2wbgdbn.onion";
    String localhost="127.0.0.1";

    Socket clientSocket = Utilities.socks4aSocketConnection(OnionAdress, hiddenServicePort, "127.0.0.1", localPort);

    ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());
    out.flush();

    out.writeObject("i am workingg");
    out.flush();
}
 
开发者ID:PanagiotisDrakatos,项目名称:T0rlib4Android,代码行数:22,代码来源:TorClientSocks4.java

示例4: doReps

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeDouble(0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readDouble();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Doubles.java

示例5: encryptObjectForURL

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/** Creates an encrypted and encode string from the source object.
 * This string can be used directly in a URL without encoding.
 * This assumes that the object passed in can be serialized.
 * @param source The source Object to encrypt/encode
 * @param key The secret key to use for encryption
 * @throws NoSuchAlgorithmException May be thrown by the Cypher module
 * @throws InvalidKeyException May be thrown by the Cypher module
 * @throws NoSuchPaddingException May be thrown by the Cypher module
 * @throws UnsupportedEncodingException May be thrown by the Cypher module
 * @throws IllegalBlockSizeException May be thrown by the Cypher module
 * @throws BadPaddingException May be thrown by the Cypher module
 * @throws NotSerializableException if the source object is not Serializable
 * @return The encoded/encrypted string
 */
public static String encryptObjectForURL(Object source, SecretKey key)
throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, javax.crypto.NoSuchPaddingException,
java.io.UnsupportedEncodingException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException,
java.io.NotSerializableException {

    Cipher desCipher = Cipher.getInstance(ENCRYPT_POLICY);
    desCipher.init(Cipher.ENCRYPT_MODE, key);

    // Copy object to byte array
    if(!(source instanceof Serializable))
        throw new NotSerializableException();
    try {
        ByteArrayOutputStream b = new ByteArrayOutputStream();
        ObjectOutputStream o = new ObjectOutputStream(b);
        o.writeObject(source);
        o.flush();
        o.close();

        return intoHexString( desCipher.doFinal( b.toByteArray() ) );
    } catch (IOException e) {
        throw new RuntimeException("No IO Exception should occur, this is all in-memory!!");
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:38,代码来源:EncryptionHelper.java

示例6: saveObjectToFile

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
public static void saveObjectToFile(LetvBaseBean baseBean, String fileName) {
    String path = getCachePath("");
    if (!TextUtils.isEmpty(path)) {
        try {
            File file = new File(path + fileName);
            file.createNewFile();
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
            objectOutputStream.writeObject(baseBean);
            objectOutputStream.flush();
            objectOutputStream.close();
            fileOutputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:FileUtils.java

示例7: doReps

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Run benchmark for given number of batches, with each batch containing
 * the given number of cycles.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, Node[] trees, int nbatches)
    throws Exception
{
    int ncycles = trees.length;
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        oout.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeObject(trees[j]);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readObject();
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:GetPutFieldTrees.java

示例8: writeWalletFile

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Methods used to write the current ClientWallent into a generated file.
 * @param userPassword
 * @param accountName
 * @param keyPair
 * @throws InvalidKeyException
 * @throws InvalidParameterSpecException
 * @throws IllegalBlockSizeException
 * @throws BadPaddingException
 * @throws FileNotFoundException
 * @throws IOException 
 */
public static void writeWalletFile(final char[] userPassword, final String accountName, final KeyPair keyPair) 
        throws InvalidKeyException,
        InvalidParameterSpecException, IllegalBlockSizeException, BadPaddingException, FileNotFoundException,
        IOException {
    
    // Write wallet information in the wallet file
    final WalletInformation walletInformation = Cryptography.walletInformationFromKeyPair(userPassword, keyPair);

    // Creates wallet folder if not exists
    final File walletFolder = new File(Parameters.WALLETS_PATH);
    if (!walletFolder.exists()) {
        walletFolder.mkdir();
    }

    // Creates new wallet file
    final File f = new File(Parameters.WALLETS_PATH + accountName + ".wallet");
    final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
    oos.writeObject(walletInformation);
    oos.flush();
    oos.close();

    System.out.println("The creation of your wallet completed successfully");
    System.out.println("Please sign in and start crashing coins");
}
 
开发者ID:StanIsAdmin,项目名称:CrashCoin,代码行数:37,代码来源:WalletClient.java

示例9: save

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Saves current state of the TT (itself).
 *
 * @return <code>true</code> if serialization was successful
 */
public boolean save() {
    try {
        // Save to file
        FileOutputStream oFOS = new FileOutputStream(this.strTableFile);

        // Compressed
        GZIPOutputStream oGZOS = new GZIPOutputStream(oFOS);

        // Save objects
        ObjectOutputStream oOOS = new ObjectOutputStream(oGZOS);

        oOOS.writeObject(this);
        oOOS.flush();
        oOOS.close();

        return true;
    } catch (IOException e) {
        System.err.println("TransitionTable::save() - WARNING: " + e.getMessage());
        e.printStackTrace(System.err);
        return false;
    }
}
 
开发者ID:souhaib100,项目名称:MARF-for-Android,代码行数:28,代码来源:TransitionTable.java

示例10: doReps

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeByte(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readByte();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Bytes.java

示例11: send

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Sends an object to the connected server
 * @param object Object Object
 * @return Boolean True if it worked, False if not
 */
public final boolean send(Object object) {
    if(!connected && !isServerClient) {
        StaticStandard.logErr("[CLIENT] Cannot send object, server is not connected");
        return false;
    }
    try {
        ObjectOutputStream oos = getObjectOutputStream();
        oos.writeObject(object);
        oos.flush();
        return true;
    } catch (Exception ex) {
        //StaticStandard.logErr("[CLIENT] Error while sending: " + ex, ex); //TODO sieht heslig aus?
        return false;
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:21,代码来源:Client.java

示例12: convertObjectToBytes

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
public static byte[] convertObjectToBytes(Object data) throws IOException
{
    byte[] pileOfBytes = null;
    FixedDeflaterOutputStream zip = null;
    try
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(200);
        zip = new FixedDeflaterOutputStream(bos);
        ObjectOutputStream oos = new ObjectOutputStream(zip);
        oos.writeObject(data);
        oos.flush();
        bos.flush();
        zip.finish();
        zip.close();
        zip = null;
        pileOfBytes = bos.toByteArray();
        bos.close();
    }
    finally
    {
        if (zip != null)
        {
            zip.finish();
        }
    }
    return pileOfBytes;
}
 
开发者ID:goldmansachs,项目名称:jrpip,代码行数:28,代码来源:ByteUtils.java

示例13: sendResponse

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private void sendResponse(ObjectOutputStream out, Object response)
		throws IOException {
	out.writeObject(response);
	out.flush();
	System.out.println("sending response to client-app...");
	System.out.println(response);
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:8,代码来源:SocketServer.java

示例14: call

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
@Override
public String call() throws Exception {

    int trials = 0;
    while(trials < Config.MESSAGE_MAX_TRIALS) {
        try {
            log.trace(p.getPeerServerPort());
            log.trace(p.getAddress());
            Socket messagedClient = new Socket(p.getAddress(), p.getPeerServerPort());
            messagedClient.setSoTimeout(Config.MESSAGE_TIMEOUT);
            ObjectOutputStream out = new ObjectOutputStream(messagedClient.getOutputStream());
            out.writeInt(Config.MESSAGE_OUTGOING_RESPONSE);
            out.writeUTF(msg);
            out.flush();

            ObjectInputStream in = new ObjectInputStream(new DataInputStream(messagedClient.getInputStream()));
            int ack = in.readInt();

            if (ack == Config.MESSAGE_ACK) {
                String response = in.readUTF();
                return response;
            } else {
                log.trace("Non flag read");
            }
            messagedClient.close();

        } catch (IOException e) {
            log.warn("EXCEPTIOON\n\n\n");
            log.warn(e);
            trials++;
            continue;
        }
        trials++;
    }
    log.warn("Message cannot be sent after " + Config.MESSAGE_MAX_TRIALS + " trials");
    log.warn(msg);
    return null;
}
 
开发者ID:CrypDist,项目名称:CrypDist,代码行数:39,代码来源:ResponsedMessageTask.java

示例15: writeTo

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
@Override
public void writeTo(final OutputStream outstream) throws IOException {
    ru.radiomayak.http.util.Args.notNull(outstream, "Output stream");
    if (this.objSer == null) {
        final ObjectOutputStream out = new ObjectOutputStream(outstream);
        out.writeObject(this.objRef);
        out.flush();
    } else {
        outstream.write(this.objSer);
        outstream.flush();
    }
}
 
开发者ID:kalikov,项目名称:lighthouse,代码行数:13,代码来源:SerializableEntity.java


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