Try this.

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * The client side stub for the RPC service.
 */
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
    String getImage(String name) throws IllegalArgumentException;
}// end GreetingService

##############################################################################

/**
 * The async counterpart of <code>GreetingService</code>.
 */
public interface GreetingServiceAsync {
    void getImage(String input, AsyncCallback<String> callback)
            throws IllegalArgumentException;
}// end GreetingServiceAsync

##############################################################################

package testes.gwt.server;

import java.io.FileInputStream;

import sun.misc.BASE64Encoder;
import testes.gwt.client.GreetingService;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
public class GreetingServiceImpl extends RemoteServiceServlet implements
        GreetingService {

    private static final long serialVersionUID = -7242788956943039085L;

    public String getImage(String input) throws IllegalArgumentException {

        try {
            BASE64Encoder base64Encoder = new BASE64Encoder();
            FileInputStream fileInputStream = new
FileInputStream("myImage");

            byte[] buffer = new byte[fileInputStream.available()];

            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("data:image/png;base64,");
            fileInputStream.read(buffer);
            stringBuilder.append(base64Encoder.encode(buffer));
            return stringBuilder.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }// end catch
        return null;
    }// end getImage
}// end GreetingServiceImpl


##############################################################################


public void onFailure(Throwable caught) {}

public void onSuccess(String result) {
    if (!img.isVisible())
           img.setVisible(true);
    img.getElement().setPropertyObject("src", result);
 } // end onSuccess


-- 
Professor Vagner

O PLANETA É O MEU PAÍS, E A CIÊNCIA É A MINHA RELIGIÃO ! INDO AO INFINITO E
ALÉM... !!!!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to