Question about file uploads

is having a file upload function on a web page a hard thing to do?
i need to do this, but i do not know where to start...
if anyone can help me out/shed some light on this for me that would be greatly appreciated!~!!!
THANKS!

No it is not particularly difficult; I let the user select a file on the client filesystem then upload to the server.
The form ENCTYPE must be multipart/form-data:
<FORM NAME="frmUpload" ENCTYPE="multipart/form-data" METHOD="POST" ACTION=...>
Use:
<INPUT TYPE="file" NAME="srcFile" SIZE="15" MAXLENGTH="40">
In my servlet:
verify:
String contentType = request.getHeader("Content-Type");
if (contentType.indexOf("multipart/form-data") < 0)     {
...handle error...
String boundary = contentType.substring(contentType.indexOf("boundary=") + 9, contentType.length());
private boolean TransferFile(ServletInputStream is, String srcFile,
String destDir,String caseNo, String boundary, String errorPage,
HttpServletRequest request, HttpServletResponse response) throws ServletException
File pathName = new File(...);
// If the target directory does not already exist then create it.
if (!pathName.exists()) {
pathName.mkdir();
if (!pathName.exists()) {  // did mkdir work?
... do lots more checking ...
boolean xferOK = false;
try {
FileOutputStream fout = new FileOutputStream(...);
byte[] nextBytes = null;
byte[] currBytes = null;
while ((nextBytes = ReadLine(is)) != null) {
if (currBytes != null) {
String snippet = "";
if (nextBytes.length - 10 <= boundary.length())
snippet = new String(nextBytes);
if (snippet.indexOf(boundary) < 0)
fout.write(currBytes, 0, currBytes.length);
else
fout.write(currBytes, 0, currBytes.length - 2);
currBytes = nextBytes;
fout.close();
xferOK = true;
catch (IOException ioe) {
return xferOK;
} // TransferFile()
Hope this helps

Similar Messages

  • Question about File upload functionality in Weblogic

    Hi,
        We're currently trying to deploy a web application on the weblogic 12c server (via war file). And the app needs to upload a text file onto the a temperary directory within weblogic server. And on the web page side, we use JQuery File upload plugin.
        My question is, on the file receiver side, does weblogic provide any tools to receive the uploaded file and store it?
    Thanks very much in advance.

    Hi,
    Before setting the string or xstring to server->response->set_cdata (string) or server->response->set_data (xstring) try this:
    CONCATENATE 'attachment;filename=' lv_filename '.xml'  INTO lv_string.
    * Setting the filename by default
      server->response->set_header_field( name  = 'Content-Disposition'
                                          value = lv_string ).
    Hope this helps.
    Regards,
    Abhinav

  • About file uploading in bdc

    hi,
    what is the use of file uploading in bdc.
    i mean that how can i see that my file was updated or not.
    or where updation has happend using this files in both
    session method and call transaction method.
    i hope u can understood my problem.
    hoping for good answer.
    thanks

    TYPE-POOLS : TRUXS.
    TYPES : BEGIN OF TYP_OUT,
      PLVAR(2)  TYPE C,
      OTYPE(2)  TYPE C,
      SEARK(12) TYPE C,
      INFTY(4)  TYPE C,
      SUBTY(4)  TYPE C,
      ISTAT(1)  TYPE C,
      BEGDA(10) TYPE C,
      ENDDA(10) TYPE C,
      RSIGN(1)  TYPE C,
      RELAT(3)  TYPE C,
      SCLAS(2)  TYPE C,
      SOBID(45) TYPE C,
    END OF TYP_OUT.
    DATA : TA_PP02 TYPE STANDARD TABLE OF TYP_OUT INITIAL SIZE 0,
           WA_PP02 TYPE TYP_OUT.
    DATA: TA_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE INITIAL SIZE 0,
           WA_EXCEL TYPE ALSMEX_TABLINE.
    DATA : RAW_DATA TYPE TRUXS_T_TEXT_DATA.
    DATA: TA_BDCDATA TYPE STANDARD TABLE OF BDCDATA ,
           WA_BDCDATA TYPE BDCDATA,
           TA_BDCMESSAGE TYPE TABLE OF BDCMSGCOLL,
           WA_BDCMESSAGE TYPE BDCMSGCOLL.
    SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
    PARAMETERS FILE_N TYPE RLGRAP-FILENAME OBLIGATORY." Path name selected by user with help of Filemngr
    SELECTION-SCREEN : END OF BLOCK BLK1 .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE_N.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    FIELD_NAME = 'FILE_N'
    IMPORTING
    FILE_NAME = FILE_N.
    START-OF-SELECTION.
    PERFORM UPLOAD.
    PERFORM BDC_OPEN.
    PERFORM BDC_SCREENS .
    PERFORM BDC_CLOSE.
    CALL TRANSACTION 'SM35'.
    *&      Form  UPLOAD
          text
    -->  p1        text
    <--  p2        text
    FORM UPLOAD .
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
      I_FIELD_SEPERATOR          =
      I_LINE_HEADER              =
        I_TAB_RAW_DATA             = RAW_DATA
        I_FILENAME                 = FILE_N
      TABLES
        I_TAB_CONVERTED_DATA       = TA_PP02[]
    EXCEPTIONS
       CONVERSION_FAILED          = 1
       OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " UPLOAD
    *&      Form  BDC_OPEN
          text
    -->  p1        text
    <--  p2        text
    FORM BDC_OPEN .
      CALL FUNCTION 'BDC_OPEN_GROUP'
       EXPORTING
         CLIENT                    = SY-MANDT
        DEST                      = FILLER8
         GROUP                     = 'PP02'
        HOLDDATE                  = FILLER8
         KEEP                      = 'X'
         USER                      = SY-UNAME
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " BDC_OPEN
    *&      Form  BDC_SCREENS
          text
    -->  p1        text
    <--  p2        text
    FORM BDC_SCREENS .
      LOOP AT TA_PP02 INTO WA_PP02.
        REFRESH TA_BDCDATA.
        PERFORM BDC_DYNPRO      USING 'SAPMH5A0' '1000'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'PPHDR-ENDDA'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM BDC_FIELD       USING 'PPHDR-PLVAR'
        WA_PP02-PLVAR.
                                 '01'.
        PERFORM BDC_FIELD       USING 'PPHDR-OTYPE'
        WA_PP02-OTYPE.
                                 'S'.
        PERFORM BDC_FIELD       USING 'PM0D1-SEARK'
        WA_PP02-SEARK.
        PERFORM BDC_FIELD       USING 'PPHDR-INFTY'
        WA_PP02-INFTY.
        PERFORM BDC_FIELD       USING 'PPHDR-SUBTY'
        WA_PP02-SUBTY.
        PERFORM BDC_FIELD       USING 'PPHDR-ISTAT'
        WA_PP02-ISTAT.
        PERFORM BDC_FIELD       USING 'PPHDR-BEGDA'
        WA_PP02-BEGDA.
        PERFORM BDC_FIELD       USING 'PPHDR-ENDDA'
        WA_PP02-ENDDA.
        PERFORM BDC_DYNPRO      USING 'SAPMH5A0' '1000'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'PPHDR-PLVAR'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=INSE'.
        PERFORM BDC_FIELD       USING 'PPHDR-PLVAR'
        WA_PP02-PLVAR.
        PERFORM BDC_FIELD       USING 'PPHDR-OTYPE'
        WA_PP02-OTYPE.
        PERFORM BDC_FIELD       USING 'PM0D1-SEARK'
        WA_PP02-SEARK.
        PERFORM BDC_FIELD       USING 'PPHDR-INFTY'
        WA_PP02-INFTY.
        PERFORM BDC_FIELD       USING 'PPHDR-ISTAT'
        WA_PP02-ISTAT.
       PERFORM BDC_FIELD       USING 'PPHDR-BEGDA'
       WA_PP02-BEGDA.
       PERFORM BDC_FIELD       USING 'PPHDR-ENDDA'
       WA_PP02-ENDDA.
      PERFORM BDC_DYNPRO      USING 'MP100100' '2000'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'P1001-SOBID'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
      PERFORM BDC_FIELD       USING 'P1001-BEGDA' WA_PP02-BEGDA.
                                 '01.12.2009'.
      PERFORM BDC_FIELD       USING 'P1001-ENDDA' WA_PP02-ENDDA.
                                 '31.12.9999'.
      PERFORM BDC_FIELD       USING 'P1001-RSIGN' WA_PP02-RSIGN.
                                 'A'.
      PERFORM BDC_FIELD       USING 'P1001-RELAT' WA_PP02-RELAT.
                                 '002'.
      PERFORM BDC_FIELD       USING 'P1001-SCLAS' WA_PP02-SCLAS.
                                 'S'.
      PERFORM BDC_FIELD       USING 'P1001-SOBID' WA_PP02-SOBID.
                                 '50001923'.
      PERFORM BDC_DYNPRO      USING 'MP100100' '2000'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'P1001-BEGDA'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=UPD'.
      PERFORM BDC_DYNPRO      USING 'SAPMH5A0' '1000'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                     'PPHDR-PLVAR'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=BACK'.
      CALL FUNCTION 'BDC_INSERT'
      EXPORTING
       TCODE                  = 'PP02'
       TABLES
        DYNPROTAB              = TA_BDCDATA.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
       PERFORM BDC_TRANSACTION USING 'PP02'.
      ENDLOOP.
    PERFORM CLOSE_GROUP.
    ENDFORM.                    " BDC_SCREENS
    *&      Form  BDC_CLOSE
          text
    -->  p1        text
    <--  p2        text
    FORM BDC_CLOSE .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
       EXCEPTIONS
         NOT_OPEN          = 1
         QUEUE_ERROR       = 2
         OTHERS            = 3
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " BDC_CLOSE
    *& Form bdc_dynpro
    *text
    *-->P_1269 text
    *-->P_1270 text
    FORM BDC_DYNPRO USING PROGRAM TYPE SY-REPID
    DYNPRO TYPE ANY.
    WA_BDCDATA-PROGRAM = PROGRAM.
    WA_BDCDATA-DYNPRO = DYNPRO.
    WA_BDCDATA-DYNBEGIN = 'X'.
    APPEND WA_BDCDATA TO TA_BDCDATA.
    CLEAR WA_BDCDATA.
    ENDFORM. " bdc_dynpro
    **& Form bdc_field
    *text
    *-->P_1329 text
    *-->P_1330 text
    FORM BDC_FIELD USING FNAM TYPE ANY
    FVAL TYPE ANY.
    IF FVAL NE ''.
    WA_BDCDATA-FNAM = FNAM.
    WA_BDCDATA-FVAL = FVAL.
    APPEND WA_BDCDATA TO TA_BDCDATA.
    CLEAR WA_BDCDATA.
    ENDIF.
    ENDFORM. " bdc_field

  • Need Tutorial about file upload

    Hi folks!
    Have anybody a link or something else to a tutorial for uploading files with JSF?
    And i mean with the "plain" JSF RI 1.2 from Sun. Google gives me a lot of Websites with Apache myFaces and myfaces extensions, but i use facelets.
    So i have to bring all the the packages together and to mutch action for my little app.
    Greetings, cpt.crispy

    Using plain JSF RI 1.2 is not possible to do what you want.That's a pity!
    So, you need to use an additional component library
    like apache tomahawk.I know that. But what does the "additional component library" do?
    Don't misunderstand me please. I want to learn how file uploads works in JSF and J2EE, not to learn some "magic" libraries.
    For most Java problems you can get "additional libraries", but sometimes it's better you make it on your own to learn how it works.
    Thanks for your reply, cpt.crispy

  • Few questions about file sharing using airport

    I'm thinking about getting an AirPort Extreme, but I have a few questions:
    1- I (must) use Ubuntu Linux at work and I would like to be able to acess my home files hosted at AirPort remotly. Is this possible?
    2- Can I access my files on my iPhone using 3G connection (eg: download or stream mp3 files, photos, ...)?
    Thanks in advance!
    Marcio

    Yes.
    Yes. Use FileBrowser for iPad.

  • Question about file size when using "Export for Web"

    Hi!
    I created a .mov file and worked to get a great balance between file size and quality so that I could deliver it via the web and make it easier for end users to see the video on a slower connection.
    My question: When I use "Export for Web," my .mov file is converted into a very large .m4v file--more than double the size of the original file. I know that this export option is to optimize the file for a wide variety of users/internet speeds. Am I correct in guessing that the end size is not an issue? I would post the .mov file instead, but I really like the option of embedding into a html page along with the "click to play" option.
    Bottom line--is it better to post the smaller .mov file that i originally started with or to go ahead and link to the bigger .m4v file that was created with the "Export for Web" option?

    "Export for Web" is a feature of QuickTime Pro and it makes 4 files and the html page code for easy copy/paste Web page editing.
    The very first file is called a "reference movie" and it links to the other 3 files (56kbps, 900kbps and 1.5Mbps). It, and the page code, "read" the connection speed of the viewing hardware and "serve up" the correct file based on that connection speed.
    In nearly all cases the "Desktop" version would still be smaller in file size than the original source. The times the file would "increase" in file size would be when an already compressed was used as the source file. You can find out more about your source file by opening it in QuickTime Player and viewing the Movie Inspector window information.
    There are dozens of other html "tricks" that could be used if your source file is already compressed but you want a different display size:
    Page code to show "aspect" or scale="tofit". This code allows values "outside" of those found in the actual QuickTime file be used for the Web page display. A 320X240 QuickTime .mov file looks pretty good at double size (640X480) but the file size would still be that of the source file.
    "Poster Movie" is another html trick that loads the Web based file directly in the QuickTime Player application (bypassing Web page layout restrictions). These files are also known as "Presentation Movies".
    Another method is the QuickTime Media Link file (.qtl). These are simple text based files that are used as a "direct link". These use simple XML (Extensible Markup Language) and are easily created in any text editing application. The simple syntax has amazing control over a simple QuickTime .mov file. You can launch (and quit) the QuickTime Player, display at other dimensions and even embed "links" inside the display.
    Some of my files as examples:
    http://homepage.mac.com/kkirkster/Lemon_Trees/ a "Poster Movie" style.
    http://homepage.mac.com/kkirkster/.Public/RedneckTexasChristmas.qtl
    A QuickTime Media Link file. A tiny file should download to the viewing machine, launch QuickTime Player, present the movie and it even includes a "link" to my Web page.
    Edit: It appears you must now double click the .qtl download to launch QuickTime.

  • I'm confused about file uploading mechanism in richfaces

    I'm going to use <rich:fileUpload> to uploading files. This is some part of my backing bean named FileUploadBean:
    private List data = new ArrayList();
    public List getFileList () {
             return data;
         public void listener(UploadEvent event){
             UploadItem item = event.getUploadItem();
             System.out.println("File : '" + item.getFileName() + "' was uploaded");
             if (item.isTempFile()) {
              File file = item.getFile();
              System.out.println("Absolute Path : '" + file.getAbsolutePath() + "'!");
              file.delete();
             }else {
                  try {
                        ByteArrayOutputStream b = new ByteArrayOutputStream();
                        b.write(item.getData());
                        System.out.println(b.toString());
                   } catch (Exception e) {
                        e.printStackTrace();
         public String test(){
              if (getData() != null ){
                   String test = getData().get(0).toString();
                   System.out.println("Ausgeben:" + test );
              return null;
         }And this is my jsf file named upload.jsp:
    <h:form enctype="multipart/form-data">
                <rich:fileUpload fileUploadListener = "#{fileUploadBean.listener}"
                        uploadData = "#{fileUploadBean.data}"
                        listWidth = "#{fileUploadBean.width}" listHeight="#{fileUploadBean.height}"
                        maxFilesQuantity = "#{fileUploadBean.maxFiles}"
                    acceptedTypes = "*">
                    <a4j:support event="onuploadcomplete" reRender="info" />
                </rich:fileUpload>
                <h:panelGroup id="info">
                    <rich:panel bodyClass="info">
                        <f:facet name="header">
                            <h:outputText value="Uploaded Files Info" />
                        </f:facet>
                    </rich:panel>
                    <rich:spacer height="3"/>
                    <br />
                    <a4j:commandButton action = "#{fileUploadBean.test}"
                        reRender="info, upload" value="Clear Uploaded Data" />
                </h:panelGroup>
        </h:form>When I do upload using this upload.jsf every thing is ok and at last I see message DONE and the lines below in console:
                    File : 'D:\Documents and Settings\Admin\My Documents\My Pictures\1_java_logo.gif' was uploaded
         Absolute Path : 'D:\DOCUME~1\Admin\LOCALS~1\Temp\6a335dad-11b25ebea8d--800021601.upload'!But I can't find any file anywhere in my computer and there is nothing in Uploaded Files panel. How can I control the destination of uploaded files? is there something wrong?

    Laura_Jlover wrote:
    I'm going to use <rich:fileUpload> to uploading files. This is some part of my backing bean named FileUploadBean:First of all, logically, you might have more luck asking RichFaces related questions in the RichFaces forum at JBoss.org instead of asking it in Sun JSF forum at Sun.com.
    System.out.println("Absolute Path : '" + file.getAbsolutePath() + "'!");
    file.delete();
    File : 'D:\Documents and Settings\Admin\My Documents\My Pictures\1_java_logo.gif' was uploaded
    Absolute Path : 'D:\DOCUME~1\Admin\LOCALS~1\Temp\6a335dad-11b25ebea8d--800021601.upload'!But I can't find any file anywhere in my computer and there is nothing in Uploaded Files panel. How can I control the destination of uploaded files? is there something wrong?I don't know how the rich:fileUpload is supposed to work (you should read its documentation at their own website), but according to the console output and the code logic you've deleted the file instead of writing it.

  • Question regarding file upload and download utility

    Hi
    I am able to upload file with file browse contorl of APEX. Now i want to download the uploaded file. Is it possible that if word document is uploaded then when user clicks on it to download, that document is directly opened in microsoft word. Of if PDF file is uploaded then on download it is opened with acorobat pdf.
    Requirement is like when user is downloading any uploaded file denpending on file type (text,excel,pdf,doc) relative application should opened with that document.
    Thanks in advance

    That is controlled by settings in the browser that you cannot change. For instance, I have my browsers configured to use FoxIt PDF reader instead of Acrobat reader for PDFs, but no website could change that. The same is true when it comes to downloading vs opening. Sorry.
    Tyler Muth
    http://tylermuth.wordpress.com
    "Applied Oracle Security: Developing Secure Database and Middleware Environments": http://sn.im/aos.book

  • QUESTION ABOUT FILES

    I want to delete an entry from a file and i'm trying not to load everything into memory at once.
    Now, what i intend doing is, as i read from the file with the data (joe.txt), if the line read from joe.txt isn't what i want to delete, i want to write that information to another file (say joe1.txt). so at the end of the day, joe1.txt will contain everything in joe.txt without the information i deleted.
    After all this is done, i want to change the fileName joe1.txt to joe.txt.
    CAN THIS BE DONE or if anybody can think of a better way of doing this without loading all information into memory.
    Thanks a lot

    The previous post about Java not being able to rename a file is incorrect File.renameTo(File) exists. Of course what you're asking can be done. I suspect you wish to remove data from a file. Look at the RandomAccessFile class:
    http://java.sun.com/j2se/1.5.0/docs/api/java/io/RandomAccessFile.html

  • About file upload

    Hi all;
    I have problem which is i down load the image in my table when i upload it it give me error like forbidden 403.
    Please help me
    thanks.

    thanks Denes to get interested
    I can upload all the doc i want with less than a total cumulated size of 100Mo. But
    I think that i've found. After have try to change different values in the SGA and PGA parameters without result, i'm almost sure my problem comes from the size of my temporary tablespace. I'm not Oracle specialist and i didn't expect this tablespace was in use during this operation. I'll make some tests but it should be work if i increase this buffer. But i don't understand, for downloading blob with 4Go size, do you have to fix temp tablespace size to 4Go?
    For those who could be interested, there is my code (don't be afraid, there is a lot of comments):
    [package client;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class DocBlobData {
        public DocBlobData(String location, Log myLog, Integer IdBlob) {
            myLog.lineWriter("**********************************************");
            myLog.lineWriter("********** START document uploading **********");
            try {
                upLoadFile(location, myLog, (blobDocQuery(myLog, IdBlob)));
                myLog.lineWriter("****** COMPLETE upload of this document ******");
                myLog.lineWriter("**********************************************");
            } catch (Exception e) {
    myLog.lineWriter("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    myLog.lineWriter("!!!!!!!! ERROR during upload operation !!!!!!!");
    myLog.lineWriter("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    * Take a document find at "location" then execute the query passed
    * as parameter for insert or update a blob into the database
    public static void upLoadFile(String location, Log myLog,
    String query) throws Exception {
    Connection conn = Log.oracleConnectionCreation();
    File myFile = new File(location.toLowerCase());
    InputStream myFileInStream = new FileInputStream(myFile);
    try {
    PreparedStatement ps = conn.prepareStatement(query);
    try {
    ps.setBinaryStream(1, myFileInStream, (int)myFile.length());
    ps.executeUpdate();
    myLog.lineWriter("following file has been uploaded");
    myLog.lineWriter("from :", myFile.getAbsolutePath());
    myLog.lineWriter("name :", myFile.getName());
    } catch (Exception e) {
    myLog.lineWriter("!!!!!!!!!! ERROR with following file !!!!!!!!!");
    myLog.lineWriter("from :", myFile.getAbsolutePath());
    myLog.lineWriter("name :", myFile.getName());
    } finally {
    ps.close();
    } finally {
    myFileInStream.close();
    conn.close();
    * Return the query "insert..." when the ID proposed doesn't already exist
    * and return "update..." if the needed ID already exists
    public static String blobDocQuery(Log myLog, Integer Id) throws Exception {
    Connection conn = Log.oracleConnectionCreation();
    String tableDoc = "DOC_BLOB";
    String columnDoc = "ABLOB";
    String id_columnDoc = "ID_BLOB";
    Integer idDoc = Id;
    String upDateDoc =
    "update " + tableDoc + " set " + id_columnDoc + " = " + idDoc +
    ", " + columnDoc + " = ? where " + id_columnDoc + " = " + idDoc;
    String insertDoc =
    "insert into " + tableDoc + " (" + id_columnDoc + ", " +
    columnDoc + ")" + " values " + "(" + idDoc + ", ?)";
    String testQuery =
    "select * from " + tableDoc + " where " + id_columnDoc + " = " +
    idDoc;
    try {
    Statement ps = conn.createStatement();
    ResultSet result = ps.executeQuery(testQuery);
    if (result.next()) {
    /* myLog.lineWriter("The query returned by blobDocQuery is :" +
    upDateDoc); */
    return upDateDoc;
    } else {
    /* myLog.lineWriter("The query returned by blobDocQuery is :" +
    insertDoc); */
    return insertDoc;
    } finally {
    conn.close();
    * Take a repertory path then found the document details in function of its ID
    * finally download the document into the repertory from the blob
    * and name it with the pattern "type_name.extension"
    public static void downloadFile(Log myLog, String location,
    Integer Id) throws Exception {
    Connection conn = Log.oracleConnectionCreation();
    String table = "DOC_BLOB"; // Table for storing the Blob
    String column = "ABLOB"; // Column for storing the Blob
    String id_column = "ID_BLOB"; // Column for storing the Id
    Integer id = Id; // Fix the id wanted
    location =
    location + "/" + DocDetailData.findTypefromBlobId(myLog, id) +
    "_" + DocDetailData.findNamefromBlobId(myLog, id) +
    DocDetailData.findExtensionfromBlobId(myLog, id);
    File myFile = new File(location.toLowerCase());
    FileOutputStream myFileOutStream = new FileOutputStream(myFile);
    myLog.lineWriter("**********************************************");
    myLog.lineWriter("********* START document downloading *********");
    try {
    String request =
    "select " + column + " from " + table + " where " + id_column +
    " = ? ";
    PreparedStatement ps = conn.prepareStatement(request);
    try {
    ps.setInt(1, id);
    ResultSet rs = ps.executeQuery();
    try {
    if (rs.next()) {
    InputStream myFileInStream =
    rs.getBinaryStream(column);
    byte[] buffer = new byte[1024];
    int length = 0;
    while ((length = myFileInStream.read(buffer)) != -1) {
    myFileOutStream.write(buffer, 0, length);
    myLog.lineWriter("***** COMPLETE download of this document *****");
    myLog.lineWriter("**********************************************");
    } finally {
    rs.close();
    } finally {
    ps.close();
    } finally {
    myFileOutStream.close();
    conn.close();
    * This main is used for testing purposes
    public static void main(String[] args) {
    Log myLog =
    Log.myLogCreation("c:/Migration Logs/", "Test_DocBlobData.log");
    Integer idEntryBlob =
    1; // Fix the Id used into the database for the Blob
    // Uncomment the following lines for testing the function blobDocQuery(Log,Integer)
    /* try {
    blobDocQuery(myLog, idEntryBlob);
    } catch (Exception f) {
    myLog.lineWriter("!!! ERROR during execution of blobDocQuery");
    // Uncomment the following lines for testing the function upLoadFile(String,Log,String)
    // You must create a document text using Notepad at the root of C with name "test"
    /* try {
    upLoadFile("c:\\image_vide.GIF", myLog, "update DOC_BLOB set ID_BLOB = 1, ABLOB = ? where ID_BLOB = 1");
    //"insert into DOC_BLOB (ID_BLOB, ABLOB) values ( 1, ?)");
    } catch (Exception f) {
    myLog.lineWriter("!!! ERROR during execution of upLoadFile");
    /* try {
    downloadFile(myLog, "c:/", 1);
    } catch (Exception e) {
    myLog.lineWriter("!!! ERROR during execution of downloadFile");
    I add just this function quite useful in my case, which enables to circulate through a folder arborescence :
    * Enable to progress through a complexe directory and each one of its dependences
    * All the documents found into this directory are uploaded into the database
    * Their details are loaded too with keeping link between the doc and its details
    public void parseFilesNUpLoad(File rootFolder,
    Log myLog) throws Exception {
    myLog.lineWriter("the root folder is : ",
    rootFolder.getAbsolutePath());
    if (rootFolder.isDirectory()) {
    File[] list = rootFolder.listFiles();
    if (list != null) {
    for (int i = 0; i < list.length; i++) {
    parseFilesNUpLoad(list[i], myLog);
    if (list[i].isFile()) {
    DocBlobData blobTest =
    new DocBlobData(list[i].getAbsolutePath(), myLog,
    idEntryBlob);
    myLog.lineWriter(" ");
    DocDetailData detailTest =
    new DocDetailData(list[i].getAbsolutePath(), myLog,
    idEntryBlob, idEntryDetails);
    myLog.lineWriter(" ");
    idEntryBlob = idEntryBlob + 1;
    idEntryDetails = idEntryDetails + 1;
    } else {
    myLog.lineWriter("parseFilesNUpLoad",
    "!!! CRITICAL ERROR with the root folder at : " +
    rootFolder.getAbsolutePath());
    And the last one, for populating the log and create the connection to the DB
    [package client;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.text.DateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.Locale;
    public class Log {
        private String fileName;
        public Log(String name) {
            this.fileName = name;
    public void lineWriter(String line) {
    try {
    FileWriter f = new FileWriter(fileName, true);
    BufferedWriter bf = new BufferedWriter(f);
    Calendar c = Calendar.getInstance();
    Date now = c.getTime();
    String dateLog =
    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM,
    Locale.FRANCE).format(now);
    bf.write("[" + dateLog + "] :" + line);
    bf.newLine();
    bf.close();
    } catch (IOException e) {
    System.out.println(e.getMessage());
    public void lineWriter(String header, String info) {
    lineWriter(header + " > " + info);
    public void lineWriter(String header, Long info) {
    lineWriter(header + " > " + info);
    public static Log myLogCreation(String location, String name) {
    boolean exists = (new File(location)).exists();
    if (!exists) {
    (new File(location)).mkdirs();
    Log myLog = new Log(location + name);
    return myLog;
    public static Connection oracleConnectionCreation() throws Exception {
    // Register the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    //connecting to the DB
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@192.192.20.1:1521:DFLY",
    "DFLYDB", "DFLYDB");
    // DriverManager.getConnection("jdbc:oracle:thin:@192.192.20.1:1521:DFLY", "DFLYDB", "DFLYDB");
    return conn;
    cheers,
    Tif

  • Odd Question about file extensions

    Hello, I have a strange question that I cannot seem to fix on my own.
    The other week I was messing around in my Utilities folder and I was clicking on some of the applications contained in that folder.
    When I closed out some of the programs that I had opened I noticed that all the files on my computer now have a suffix at the end of their names. Everything.
    So before an application would say, TechTool Pro 4 it now says TechTool Pro 4.app
    TextEdit.app, etc etc
    I know this is a minor thing but I would like to find a way to remove this suffix that I inadvertently applied to everything on my laptop.
    Thanks for the help

    See if this helps. Go to Finder choose Preferences then click Advanced. See if the *Show all file extensions* box is checked. If it is uncheck it.

  • Question about files in J2ME

    Good Evening all!
    First off, I am creating a Registry web site for vintage BMW's (02 Series) and I have considered creating a MIDlet J2ME to use along side the web site. I plan to use the app on cell phones, especially ones with cameras.
    Now my question:
    How can I find out where the picture files are located on the device?
    PS. I am comfortable with J2SE, but am new to the J2ME scene.
    Thanks!

    np. In J2ME you can't access any phone-specific functions like the phonebook, sms inbox, dialing or things like this. So you also cant access and load image located in the "normal" file system of the phone. The only storage you can access with your MIDlet is the RMS, but this is MIDlet dependent (each MIDlet has its own RMS).
    This is valid for J2ME. I dont know, whether there are some phone specific APIs, which let you do such things. But the use of them is not recommended, since your app then requires some specific phones, and will not run on every J2ME-enabled phone.
    Kay

  • Question about File Descripters

    I am new to Java so forgive my ignorance...
    I was wondering that why this FileDescriptor class is all about?? anyone give me any example(easy)
    I am new.. but don't worry.. i know java io streams well...
    I will appreciate you help!!
    MOIN.

    Hi!
    As long as I know, the main use of a FileDescriptor is to ensure the flushing of file buffers to disk by using the sync() method.
    It is, if you have a FileOutputStream (or any stream connected to it) you cannot be sure that calling the flush() method will flush O.S. buffers to disk. The only way to do that is by means of:
    FileOutputStream out = new FileOutputStream( "xxx.yyy" );
    .... // write here your data
    // The following only flushes FileOutputStream buffers (if any)
    out.flush();
    // Try to flush O.S. buffers
    out.getFD().sync();Take a look at "JAVA I/O" by E. R. Harold for more info.
    Bye.

  • Quick Question about Files Menu / F8

    Until about a week ago, when I pressed F8 Dreamweaver brought up the files menu.  Now when I press this function key it brings up the Page Properties dialogue box.  Any ideas how to reset my F8 key?

    I am assuming that you mean Window > Workspace Layout > (Something different)  then Window > Workspace Layout > (back to original setting) which doesn't fix the problem.  Thanks for the suggestion though.  If you meant something different I would appreciate the help.
    BTW when I go to Dreamweaver > Keyboard Shortcuts...  the shortcuts are correct i.e. Files is listed as F8 and Page Properties is command J.

  • Question about file conversion in the sender file adapter

    Hi, all.
    I am trying to get the file adapter to parse a file. The message type is the following:
    JOB
       Msg  0..1
          Transaction  0 ... unbounded
             Data   0 ... 1
                f1 string
                f2 string
    How would you define the recordset name and recordset structure to produce the same structure in the converted xml. I tried:
    recordset name : Msg
    recordset structure : Data, *
    But the transaction is missing. I tried:
    recordset name: Msg
    recordset structure : Transaction, *
    Then the data is missing. Note that the actual data in f1, f2 ... are loaded successfully though.
    Thanks,
    Jonathan.

    Hi, Hareesh
    I agree. But that is how it is defined now by someone else. It is hard to change it as he defines the same structure on the receiving side. I didn't want to change the receiving structure as it touches the proxy code too. So I want to make something short and sweet.
    Basically the data looks like this:
    11,222
    55,666
    The result xml should be something like:
    <JOB>
      <Msg>
         <Transaction>
            <DATA>
               11
               222
            </DATA>
         </Transaction>
         <Transaction>
            <DATA>
              55
              666
            </DATA>
          </Transaction>
      </MSG>
    </JOB>
    I know either the DATA has no meaning and it's giving me a headache ... but that's how it's done and I don't want to rock the boat too much. There are lots of mapping that I have changed otherwise.
    Thanks,
    Jonathan.

Maybe you are looking for

  • Not able to get changed values in the SAVE EVENT in ServHPartnerDet view

    Hi Experts, I am new CRM WEB IC, i have requirement like need to access four IBASE fields from BupaIbaseDetail and need to display those fiedls in ServHPartnerDet view. I am able display the fields and its values in the target view. But when user pre

  • PDF Preview Handler Issue

    Hi I have a Windows 7 (64-bit) / Outlook 2007 / Adobe Reader XI setup where I can view PDF files via web browsing (IE) but not through Outlook attachments or Windows Explorer. I've tried... What appears to be the common registry fix / validation and

  • Video Converter Recommend

    Hi guys, just to ask something.. I've tried every converter that i could try and i cant get a good quality video that i wanted, I tried this following softwares and the output i've got. Xilisoft-video and sound are perfect but sounds comes first. (me

  • Item category TA TAN cannot be invoiced with billing type F2

    Hi, I'm new to SAP SD . when i try to create billing for  a sales order the error is as follows: "Item category TA TAN cannot be invoiced with billing type F2" Please help me in solving this. Thanks, Challa

  • I need to know the department column in Oracle Application

    Hi there: Can somebody tell me how can I get the employee department information from oracle application. I need to know the table name and column name. Thanks and regards, Zeeshan