本文整理匯總了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();
}
}
示例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();
}
示例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 );
}
示例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);
}
示例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();
}
示例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();
}
示例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));
}
示例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();
}
示例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();
}