Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic loadFrom , saveTo for Streaming . (Read 1663 times)
gamjaradio
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 42
Joined: Jul 16th, 2010
loadFrom , saveTo for Streaming .
Aug 5th, 2010 at 2:43am
Print Post  
I'm in a project using socket communication.

so need to send the Stream for my picture of Diagram.

but, I cant know how to save and Load.

I know there is the method , saveTo, loadFrom.
but need to have an example.

please give me the advice of saveTo(OutputStream),
and loadFrom(InputStream)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFrom , saveTo for Streaming .
Reply #1 - Aug 5th, 2010 at 7:40am
Print Post  
This save and loads from a memory stream:

Code
Select All
ByteArrayOutputStream out = new ByteArrayOutputStream();
try
{
	diagram.saveTo(out);
}
catch (IOException e)
{
	JOptionPane.showMessageDialog(this, e.getMessage());
	return;
}

ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
try
{
	diagram.loadFrom(in);
	out.close();
	in.close();
}
catch (IOException e)
{
	JOptionPane.showMessageDialog(this, e.getMessage());
	return;
} 



I don't know if these methods will work with network streams. If they don't, you can use the saveToString and loadFromString methods instead, and send the string across the network.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint