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


Java PipedOutputStream.connect方法代码示例

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


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

示例1: main

import java.io.PipedOutputStream; //导入方法依赖的package包/类
public static void main(String[] args) {
    /**
     * 流程
     * 1 建立输入输出流
     * 2 绑定输入输出流
     * 3 向缓冲区写数据
     * 4 读取缓冲区数据
     */
    PipedOutputStream out = new PipedOutputStream();
    PipedInputStream in = new PipedInputStream();
    Producer producer = new Producer(out);
    Consumer consumer = new Consumer(in);

    try {
        out.connect(in);
        producer.start();
        consumer.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:followwwind,项目名称:javadesign,代码行数:22,代码来源:PipedTest.java

示例2: setup

import java.io.PipedOutputStream; //导入方法依赖的package包/类
@Before public void setup() throws IOException {
	PipedInputStream inClient = new PipedInputStream();
	PipedOutputStream outClient = new PipedOutputStream();
	PipedInputStream inServer = new PipedInputStream();
	PipedOutputStream outServer = new PipedOutputStream();
	
	inClient.connect(outServer);
	outClient.connect(inServer);
	server = new AssertingEndpoint();
	serverLauncher = LSPLauncher.createServerLauncher(ServiceEndpoints.toServiceObject(server, LanguageServer.class), inServer, outServer);
	serverListening = serverLauncher.startListening();
	
	client = new AssertingEndpoint();
	clientLauncher = LSPLauncher.createClientLauncher(ServiceEndpoints.toServiceObject(client, LanguageClient.class), inClient, outClient);
	clientListening = clientLauncher.startListening();
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:17,代码来源:LauncherTest.java

示例3: init

import java.io.PipedOutputStream; //导入方法依赖的package包/类
/**
 * Initializes a parser and its plumbing.
 *
 * @throws java.io.IOException if a pipe cannot be formed.
 */
public synchronized void init() throws IOException
{
    parserIn = new PipedOutputStream();
    PipedInputStream in = new PipedInputStream();
    parserIn.connect( in );
    antlrSchemaConverterLexer lexer = new antlrSchemaConverterLexer( in );
    parser = new antlrSchemaConverterParser( lexer );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:14,代码来源:SchemaParser.java

示例4: redirectOut

import java.io.PipedOutputStream; //导入方法依赖的package包/类
private void redirectOut() throws IOException {
	PipedOutputStream pipedOutputStream = new PipedOutputStream();
	PrintStream printStream = new PrintStream(pipedOutputStream);
	System.setOut(printStream);

	PipedInputStream pipedInputStream = new PipedInputStream();
	pipedOutputStream.connect(pipedInputStream);

	addOutput(pipedInputStream);
}
 
开发者ID:Azzurite,项目名称:MinecraftServerSync,代码行数:11,代码来源:LocalConsole.java

示例5: setup

import java.io.PipedOutputStream; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
  wire = new Wire();
  outputStream = new PipedOutputStream();
  inputStream = new PipedInputStream();
  outputStream.connect(inputStream); 
  person = new Person.Builder()
                            .id(id)
                            .name(name)
                            .build();

  friends.add("foo");
  friends.add("bar");
  cleartextFriends = new CleartextFriends.Builder()
                                         .friends(friends)
                                         .build();
  nullFriends = new CleartextFriends.Builder()
                                         .friends(new ArrayList<String>())
                                         .build();
                                        
  messages.add(new RangzenMessage.Builder()
                                 .text("foo")
                                 .priority(0.25)
                                 .build());
  messages.add(new RangzenMessage.Builder()
                                 .text("bar")
                                 .priority(0.75325)
                                 .build());
  cleartextMessages = new CleartextMessages.Builder()
                                           .messages(messages)
                                           .build();
}
 
开发者ID:casific,项目名称:murmur,代码行数:33,代码来源:WireTest.java

示例6: setUp

import java.io.PipedOutputStream; //导入方法依赖的package包/类
/** Runs before each test. */
@Before
public void setUp() throws IOException {
  outputStream = new PipedOutputStream();
  inputStream = new PipedInputStream();
  testOutputStream = new PipedOutputStream();
  testInputStream = new PipedInputStream();

  // We'll hear what the exchange says via testInputStream,
  // and we can send data to it on testOutputStream.
  testOutputStream.connect(inputStream);
  outputStream.connect(testInputStream);

  SlidingPageIndicator context = Robolectric.buildActivity(SlidingPageIndicator.class).create().get();

  messageStore = new MessageStore(context, StorageBase.ENCRYPTION_DEFAULT); 
  friendStore = new FriendStore(context, StorageBase.ENCRYPTION_DEFAULT); 


  callback = new ExchangeCallback() {
    @Override
    public void success(Exchange exchange) {
    }

    @Override
    public void failure(Exchange exchange, String reason) {
    }
  };

  Robolectric.getBackgroundScheduler().pause();
  // Robolectric.getUiThreadScheduler().pause();
}
 
开发者ID:casific,项目名称:murmur,代码行数:33,代码来源:ExchangeTest.java

示例7: testPopLength

import java.io.PipedOutputStream; //导入方法依赖的package包/类
/**
 * Test the static utility method that grabs the first four bytes from an
 * input stream and returns their value as an int.
 */
@Test
public void testPopLength() throws IOException {
  int testValue = 42;
  PipedInputStream inputStream = new PipedInputStream();
  PipedOutputStream outputStream = new PipedOutputStream();
  outputStream.connect(inputStream);
  
  ByteBuffer b = ByteBuffer.allocate(4);
  b.order(ByteOrder.BIG_ENDIAN);   // Network byte order.
  b.putInt(testValue);
  outputStream.write(b.array());
  assertEquals(testValue, Exchange.popLength(inputStream));
}
 
开发者ID:casific,项目名称:murmur,代码行数:18,代码来源:ExchangeTest.java

示例8: setUp

import java.io.PipedOutputStream; //导入方法依赖的package包/类
/** Runs before each test. */

  @Before
  public void setUp() throws IOException {
    outputStreamA = new PipedOutputStream();
    inputStreamA = new PipedInputStream();
    outputStreamB = new PipedOutputStream();
    inputStreamB = new PipedInputStream();

    // We'll hear what the exchange says via testInputStream,
    // and we can send data to it on testOutputStream.
    outputStreamA.connect(inputStreamB);
    outputStreamB.connect(inputStreamA);

    SlidingPageIndicator context = Robolectric.buildActivity(SlidingPageIndicator.class).create().get();

    messageStoreA = new MockMessageStore(context, StorageBase.ENCRYPTION_DEFAULT); 
    friendStoreA = new MockFriendStore(context, StorageBase.ENCRYPTION_DEFAULT); 
    messageStoreB = new MockMessageStore(context, StorageBase.ENCRYPTION_DEFAULT); 
    friendStoreB = new MockFriendStore(context, StorageBase.ENCRYPTION_DEFAULT); 

    callback = new ExchangeCallback() {
      @Override
      public void success(Exchange exchange) {
      }

      @Override
      public void failure(Exchange exchange, String reason) {
      }
    };

    Robolectric.getBackgroundScheduler().pause();
    // Robolectric.getUiThreadScheduler().pause();
  }
 
开发者ID:casific,项目名称:murmur,代码行数:35,代码来源:BandwidthMeasurementExchangeTest.java

示例9: setUp

import java.io.PipedOutputStream; //导入方法依赖的package包/类
/** Runs before each test. */
@Before
public void setUp() throws IOException {
  // Test friends have to be real base64 encoded strings, otherwise we get
  // weird behavior. This needs to be fixed in the system.
  TEST_FRIEND_1 = "TESTFRIEND1".getBytes("UTF-8");
  TEST_FRIEND_2 = "TESTFRIEND2".getBytes("UTF-8");
  TEST_FRIEND_3 = "TESTFRIEND3".getBytes("UTF-8");
  TEST_FRIEND_4 = "TESTFRIEND4".getBytes("UTF-8");
  TEST_FRIEND_5 = "TESTFRIEND5".getBytes("UTF-8");
  TEST_FRIEND_6 = "TESTFRIEND6".getBytes("UTF-8");

  outputStreamA = new PipedOutputStream();
  inputStreamA = new PipedInputStream();
  outputStreamB = new PipedOutputStream();
  inputStreamB = new PipedInputStream();

  // We'll hear what the exchange says via testInputStream,
  // and we can send data to it on testOutputStream.
  outputStreamA.connect(inputStreamB);
  outputStreamB.connect(inputStreamA);

  SlidingPageIndicator context = Robolectric.buildActivity(SlidingPageIndicator.class).create().get();

  messageStoreA = new MockMessageStore(context, StorageBase.ENCRYPTION_DEFAULT); 
  friendStoreA = new MockFriendStore(context, StorageBase.ENCRYPTION_DEFAULT); 
  messageStoreB = new MockMessageStore(context, StorageBase.ENCRYPTION_DEFAULT); 
  friendStoreB = new MockFriendStore(context, StorageBase.ENCRYPTION_DEFAULT); 

  callback = new ExchangeCallback() {
    @Override
    public void success(Exchange exchange) {
    }

    @Override
    public void failure(Exchange exchange, String reason) {
    }
  };

  Robolectric.getBackgroundScheduler().pause();
  // Robolectric.getUiThreadScheduler().pause();
}
 
开发者ID:casific,项目名称:murmur,代码行数:43,代码来源:CryptographicExchangeTest.java


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