Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. ObjectOutputStream.writeObject(objaBasicFileAction);
  2.  
  3. package com.mypackage.actions;
  4.  
  5. import java.io.Serializable;
  6.  
  7. public abstract class BasicFileAction implements Serializable{
  8. private int[] objcFileBytes;
  9. private String scFileName;
  10.  
  11. public int[] getFileBytes(){
  12. return objcFileBytes;
  13. }
  14.  
  15. public void setFileBytes( int[] objaFileBytes ){
  16. objcFileBytes = objaFileBytes;
  17. }
  18.  
  19. public String getFileName(){
  20. return scFileName;
  21. }
  22.  
  23. public void setFileName(String saFileName){
  24. scFileName = saFileName ;
  25. }
  26. public abstract Object execute() throws Exception;
  27.  
  28. }
  29.  
  30. public Object executeService(BasicFileAction objaBasicFileAction)
  31. throws Exception {
  32. URL objlURLServer = null;
  33. ObjectInputStream objlResponse = null;
  34. Object objlObjectResult = null;
  35. URLConnection objlURLConnection = null;
  36. ObjectOutputStream objlRequest = null;
  37. TunnelException exclTunnelException = null;
  38.  
  39. try {
  40. objlURLServer = new URL((String) objcProperties.get(
  41. FileRemoteHandler.SERVICE_NAME));
  42. } catch (MalformedURLException e) {
  43. throw new Exception(
  44. "No se puede efectuar la conexion al servidor de fotografias '" +
  45. (String) objcProperties.get(FileRemoteHandler.SERVICE_NAME) +
  46. "' : " + e.getMessage());
  47. }
  48.  
  49. try {
  50. objlURLConnection = objlURLServer.openConnection();
  51. objlURLConnection.setDoOutput(true);
  52. objlURLConnection.setUseCaches(false);
  53. objlURLConnection.setRequestProperty("Content-Type",
  54. "application/octet-stream");
  55. System.out.println("terminando1");
  56. objlRequest = new ObjectOutputStream(new BufferedOutputStream(
  57. objlURLConnection.getOutputStream()));
  58.  
  59. try{
  60. objlRequest.writeObject(objaBasicFileAction); //De aquí no pasa con las imágenes mayores a 3.68MB
  61.  
  62. objlRequest.flush();
  63. objlRequest.close();
  64. }catch(NotSerializableException r){
  65. System.out.println("1 "+r.getMessage());
  66. } catch(InvalidClassException t){
  67. System.out.println("2 "+t.getMessage());
  68. } catch(IOException w){
  69. System.out.println("3 "+w.getMessage());
  70. }
  71.  
  72. // get the result input stream
  73. objlResponse = new ObjectInputStream(new BufferedInputStream(
  74. objlURLConnection.getInputStream()));
  75.  
  76. // read response back from the server
  77. objlObjectResult = objlResponse.readObject();
  78.  
  79. if (objlObjectResult instanceof TunnelException) {
  80. exclTunnelException = (TunnelException) objlObjectResult;
  81. throw new Exception(exclTunnelException.getMessage());
  82. }
  83.  
  84. } catch (Exception exclException) {
  85. System.out.println("here: "+exclException.getMessage());
  86. throw new Exception("Error al Ejecutar la Peticion : " +
  87. exclException.getMessage());
  88. }
  89.  
  90. return objlObjectResult;
  91. }
  92.  
  93. 3.68MB (3867314)
  94. 3.19MB (3355578)
  95. 3.05MB (3204054)
  96.  
  97. 4.09MB (4293306)
  98. 4.36MB (4572533)
  99. 3.81MB (3997079)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement