Created
November 7, 2012 09:05
-
-
Save sandorkan/4030299 to your computer and use it in GitHub Desktop.
Writing Data with DataWriter from HelloPublisher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.out.println("Ready to write data."); | |
System.out.println("When the subscriber is ready, you can start writing."); | |
System.out.print("Press CTRL+C to terminate or enter an empty line to do a clean shutdown.\n\n"); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
try | |
{ | |
while (true) { | |
System.out.print("Please type a message> "); | |
String toWrite = reader.readLine(); | |
dataWriter.write(toWrite, InstanceHandle_t.HANDLE_NIL); | |
if (toWrite.equals("")) break; | |
} | |
} | |
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} catch (RETCODE_ERROR e) { | |
// This exception can be thrown from DDS write operation | |
e.printStackTrace(); | |
} | |
System.out.println("Exiting..."); | |
// Deleting entities of DomainParticipant and DomainParticipant | |
participant.delete_contained_entities(); | |
DomainParticipantFactory.get_instance().delete_participant(participant); | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment