<rdf:RDF
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xml:base='http://www.mobile-j.de/snipsnap/rdf'>
    <s:Snip rdf:about='http://www.mobile-j.de/snipsnap/rdf#Fun/Send+PC+screen+to+SU2'
         s:cUser='bjoernQ'
         s:oUser='bjoernQ'
         s:mUser='bjoernQ'>
        <s:name>Fun/Send PC screen to SU2</s:name>
        <s:content>Here a java code snipped that takes a screenshot of your PC desktop and sends it to a Nokia SU-2 (or any other bluetooth JPEG viewer ...)&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;package scr2su2;&#xD;&#xA;&#xD;&#xA;import de.avetana.javax.obex.ClientSession;&#xD;&#xA;import de.avetana.javax.obex.HeaderSet;&#xD;&#xA;import de.avetana.javax.obex.Operation;&#xD;&#xA;import de.avetana.obexsolo.OBEXConnector;&#xD;&#xA;import java.awt.Rectangle;&#xD;&#xA;import java.awt.image.BufferedImage;&#xD;&#xA;import java.io.ByteArrayOutputStream;&#xD;&#xA;import javax.imageio.ImageIO;&#xD;&#xA;&#xD;&#xA;public class Main {&#xD;&#xA;    &#xD;&#xA;    &#xD;&#xA;    /**&#xD;&#xA;     * @param args the command line arguments&#xD;&#xA;     */&#xD;&#xA;    public static void main(String[] args) {&#xD;&#xA;        // TODO code application logic here&#xD;&#xA;        try{&#xD;&#xA;            &#xD;&#xA;            for(int j=0;j&lt;100;j++){  // 100 times change this&#xD;&#xA;            java.awt.Robot roby = new java.awt.Robot();&#xD;&#xA;            Rectangle screenRect = new Rectangle(0,0,640,480); // SU2 can only handle images up to VGA resolution&#xD;&#xA;            BufferedImage img = roby.createScreenCapture(screenRect);&#xD;&#xA;            &#xD;&#xA;            ByteArrayOutputStream baos = new ByteArrayOutputStream();&#xD;&#xA;            &#xD;&#xA;            ImageIO.write(img, &quot;jpeg&quot;, baos );&#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;&#xD;&#xA;            // change the address to the bluetooth address of your SU2&#xD;&#xA;            String adr = &quot;btgoep://0002EE9340ED:13;authenticate=false;encrypt=false;master=false&quot;;&#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;            ClientSession cs = (ClientSession) OBEXConnector.open(adr);&#xD;&#xA;            HeaderSet hs = cs.connect(cs.createHeaderSet());&#xD;&#xA;&#xD;&#xA;            byte[] text = baos.toByteArray();&#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;            hs.setHeader(HeaderSet.NAME, &quot;test.jpg&quot;);&#xD;&#xA;            hs.setHeader(HeaderSet.TYPE, &quot;image/jpeg&quot;);&#xD;&#xA;            //hs.setHeader(0x49, text); // if everything fits inside a packet, the data can be packed in the PUT command&#xD;&#xA;            hs.setHeader(HeaderSet.LENGTH, new Long(text.length) );&#xD;&#xA;            Operation po = cs.put(hs);&#xD;&#xA;            System.out.println(&quot;put....&quot;);&#xD;&#xA;            java.io.OutputStream os = po.openOutputStream();&#xD;&#xA;            int of=0;&#xD;&#xA;            do{&#xD;&#xA;                int le = 64;&#xD;&#xA;                if(le+of&gt;text.length) le=text.length-of;&#xD;&#xA;                &#xD;&#xA;                os.write(text,of,le );&#xD;&#xA;                &#xD;&#xA;                os.flush();&#xD;&#xA;                of+=le;&#xD;&#xA;            }while(of&lt;text.length);&#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;            &#xD;&#xA;            po.close();&#xD;&#xA;            cs.disconnect(null);&#xD;&#xA;            cs.close();&#xD;&#xA;&#xD;&#xA;// you should add a Thread.sleep(..) here because SU2 can&apos;t handle that otherwise&#xD;&#xA;&#xD;&#xA;            }&#xD;&#xA;            &#xD;&#xA;        } catch (Throwable e) {&#xD;&#xA;            e.printStackTrace();&#xD;&#xA;        }&#xD;&#xA;        &#xD;&#xA;        &#xD;&#xA;    }&#xD;&#xA;    &#xD;&#xA;}&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;The code above needs BlueCove and AvetanaOBEX in your classpath to work. You should change the bluetooth address to the address of your SU-2.&#xD;&#xA;&#xD;&#xA;Now you can watch your PCs desktop on your TV.&#xD;&#xA;&#xD;&#xA;Sending stuff to your SU-2 you should send the bytes in small chunks and set the  type to image/jpeg.</s:content>
        <s:mTime>2005-08-06 10:42:41.524</s:mTime>
        <s:cTime>2005-08-06 10:42:41.524</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li>
                    <s:Snip rdf:about='http://www.mobile-j.de/snipsnap/rdf#Fun/Send+PC+screen+to+SU2'>
                        <s:attachments
                             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
                    </s:Snip>
                </rdf:li>
                <rdf:li rdf:resource='#snipsnap-index'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#Fun/Send+PC+screen+to+SU2/'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Putting together BlueCove and avetanaOBEX'/>
                <rdf:li rdf:resource='#snipsnap-search'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Fun with sending mms from a midlet'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Reading files from J2ME on a 6600'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Getting content from a MIDlet into the phone'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#Fun/Send captured images from phone to SU2'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Sending SMS from MIDlet without user intervention'/>
                <rdf:li rdf:resource='#Fun'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#Fun/Check the mobile friendliness of your URLs'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Self signed midlets for the lazy bones'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Sending blinking sms to older Nokias ...'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/How to verify the phone&apos;s MSISDN'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#Fun/Send PC screen to SU2/'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#Fun/'/>
                <rdf:li rdf:resource='http://www.mobile-j.de/snipsnap/rdf#J2ME/Guessing the network operator'/>
            </rdf:Bag>
        </s:snipLinks>
    </s:Snip>
</rdf:RDF>
