Read file n strore to variable

hi
my program is about reading sequence from a file..
my problem is how to store the sequence into variable call line
actually i've tried but didnt work... it seems store nothing in variable line when i start to print out ..
so any solution for this critical problem?????
import java.io.*;
public class reader {
public static void main (String[] args) {
reader a = new reader(); // create object a
a.readMyFile(); // call method readmyfile
void readMyFile() {
int recCount = 0;
          String line, seq;
try {
File f = new File("hxk_yeast.fasta");
int size = (int) f.length();
FileInputStream istr = new FileInputStream(f);
InputStreamReader irdr = new InputStreamReader( istr );
BufferedReader brdr = new BufferedReader( irdr );
System.out.println("\n\npanjang:"+ size);
               while ( (line = brdr.readLine()) != null )
               recCount++;
               System.out.println("\n\t"+recCount+"line isi > "+line);
System.out.println();
// give null value ??????
System.out.println(line);
} catch (IOException e) {
System.out.println("Uh oh, got an IOException error!" + e.getMessage());
} finally {
System.out.println("brjaya");

Try this
String tmp = null;
while ( (tmp = brdr.readLine()) != null )  {
    recCount++;
     line = tmp;
    System.out.println("\n\t"+recCount+"line isi  "+line);
}That will make line set to the last line. If you want all lines concatenated to one single line, then do this:
String tmp = null;
StringBuffer result = new StringBuffer();
while ( (tmp = brdr.readLine()) != null )  {
    recCount++;
     result.append(tmp);
    System.out.println("\n\t"+recCount+"line isi  "+line);
line = result.toString();/Kaj

Similar Messages

  • How to read a file present in a variable?

    I have a info object in a variable. And i need to read the text table of that info object in the program.
    Is it possible to read a table whose name is present in a variable?
    Please provide me pointers ASAP.

    Hi ,
    Thanking you both for your replies.
    But my problem is not yet solved.
    when i tried to use () for the table name in the variable , showing error like it is not declared in the tables. When i have done it - error like the table is not present in the dictionary.
    Swami,
    My problem is i get the name of the table only in that program , where in the same program i need to read that table in the variable.
    Any more pointers plz.

  • Reading file from an external folder.

    Iam tring to read an external file from the C:\ drive. Given below is the code.
    DATA LV_XLS(100) TYPE C.
    DATA LV_CONTENT TYPE XSTRING.
    LV_XLS = 'C:\XML\Report.xls'
    READ DATASET LV_XLS INTO LV_CONTENT.
    But when i execute iam getting an error - FILE NOT FOUND. How do i read file from an external folder. My requirement is to strictly read from an external folder. Please help.
    If this is not possible please advice as to how the file could be moved to the SAP root directory. Iam not able to locate the root.

    hi,
    This is the code to read a excel file from the local system.
    Read data set you are using in your code corresponds to files on application server thats the reason its throwing an error.
    * Parameter variable declaration for browsing the file location       *
    PARAMETERS:
      p_file TYPE ibipparms-path OBLIGATORY.
    data:
    it_text TYPE truxs_t_text_data .
    AT SELECTION-SCREEN  ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         program_name        = syst-cprog
    *   DYNPRO_NUMBER       = SYST-DYNNR
         field_name          = ' '
       IMPORTING
         file_name           = p_file.
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
    *   I_FIELD_SEPERATOR          =
    *   I_LINE_HEADER              =
          i_tab_raw_data             = it_text
          i_filename                 = p_file
        TABLES
          i_tab_converted_data       = t_cust
      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.
    This is to read a text file from local system.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
        filename                      =  'D:\FILEINTERFACE\file.TXT'
    *    FILETYPE                      = 'ASC'
         has_field_separator           = 'X'
    *    HEADER_LENGTH                 = 0
    *    READ_BY_LINE                  = 'X'
    *    DAT_MODE                      = ' '
    *    CODEPAGE                      = ' '
    *    IGNORE_CERR                   = ABAP_TRUE
    *    REPLACEMENT                   = '#'
    *  IMPORTING
    *    FILELENGTH                    =
    *    HEADER                        =
        TABLES
          data_tab                      = t_kna1
    *  EXCEPTIONS
    *    FILE_OPEN_ERROR               = 1
    *    FILE_READ_ERROR               = 2
    *    NO_BATCH                      = 3
    *    GUI_REFUSE_FILETRANSFER       = 4
    *    INVALID_TYPE                  = 5
    *    NO_AUTHORITY                  = 6
    *    UNKNOWN_ERROR                 = 7
    *    BAD_DATA_FORMAT               = 8
    *    HEADER_NOT_ALLOWED            = 9
    *    SEPARATOR_NOT_ALLOWED         = 10
    *    HEADER_TOO_LONG               = 11
    *    UNKNOWN_DP_ERROR              = 12
    *    ACCESS_DENIED                 = 13
    *    DP_OUT_OF_MEMORY              = 14
    *    DISK_FULL                     = 15
    *    DP_TIMEOUT                    = 16
    *    OTHERS                        = 17
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    PS.  In both of the above mentioned function modules make sure that the file structure is similar to the internal tables used.
    Thanks
    Sharath

  • FILE ADAPTER NOT READING FILE.

    HI, GUYS.
    I'M USING A FILE ADAPTER TO READ A FILE THAT HAVE 4 REGISTERS AND EACH REGISTER ONLY HAS ONE FIELD THAT IS NUMBER TYPE.
    I CREATE THE FILE ADAPTER, AND I LET BPEL TO CREATE THE SCHEMA. THE IDE CALLS THES FIELD "C1". I ALSO CONFIGURE THAT THE FILE THAT MUST RAD IS THE PATTERN "*.TXT" AND EVERY 5 SECONDS.
    THEN A CREATE A RECEIVE ACTIVITY THAT RECEIVES WHAT WAS READ FROM THE FILE ADAPTER IN A VARIABLE.
    THEN I CREATE AN ASSIGN ACTIVITY AND I ASSIGN THE VALUE FROM THE RECEIVE ACTIVITY VARIABLE TO A NUMBER VARIABLE THAT IS THE INPUT OF A WEB SERVICE.
    THEN I DEPLOY THE BPEL, AND I INITIATE IT, BUT I GOT AN ERROR THAT SAYS THAT THE FIELD "C1" IS EMPTY. SO LOOKS LIKE THE FILE ADAPTER IS NOT READING THE FILE. I WOULD THANK ANY HELP THAT YOU CAN BRING ME.

    caps off
    You're sure the interface of the fileadapter (client partnerlink) is the same as your data-file which needs to be picked up?
    can you paste the content of the file and the content of the xsd of the process.

  • How to read files on server from a java program?

    Hello,
    I am fairly new to JSP programming. I have an issue with reading files. I am trying to call method of a normal java file from a jsp program. The method I am trying to call does some IO operation on Files. I have the files in the same directory as my class files on server that is in WEB-INF/classes folder. In my java program, I am giving just the file name to open because the files and the classes are in the same directory. But this is not working.
    What exactly should I do to read a file from a java program, that is running on the server?
    Any help is appreciated.
    Thanks,
    Krishna

    String realFilePath = application.getRealPath("/WEB-INF/myFile.txt");
    File fileToOpen = new File(realFilePath);
    out.println(fileToOpen.getAbsolutePath() + ": exists? " + fileToOpen.exists());in this case "application" is a reference to the ServletContext.
    It is an implicit variable in a JSP. In a servlet:
    ServletContext application = getServletConfig().getServletContext();

  • File information -- How to retrieve file name from header variable

    Hi
    I am using File Adapters to read files(.xml) and then I need to perform some database operations.
    One of the requirement is storing the file name read into the DB.
    I searched through the forum and got the information on how to configure this in the header variable. The link below shows the same.
    File Adapter
    Now, I use the XSL mapper to map the source values(from input xml file) to the corresponding table column names. So how should I get the value of the file name.
    I saw some of the in-built functions to be used for this but there is not enough documentation to proceed.
    Can anyone please provide some solution on this.
    /Kiran.

    Hi,
    Here are the steps that you need to do after you have declared the variable.
    1) The variable that you have declared should have the following elements
    a) Filename
    b) Directory
    2) Use the assign activity to copy the value of the filename part of this variable to the arg that needs to be passed to the database. (most probably an invoke variable).
    If you still have any problems implementing this, mail me at [email protected]..and i'll send you the screen shots for the entire process.
    ciao,
    Gunjan

  • HOW to read file using ftp???

    Hi to all,
    I have problem with reading file using ftp connection, i want to read only 1024 bytes for one time, and i have
    next code wich read this:
    byte buffer[] = new byte[1024];
    while( (readCount = input.read(buffer)) > 0) {
    bos.write(buffer, 0, readCount);
    but I dont know how to put all read data in one byte[] if i dont know length of file.
    I can't do some like: byte file[] = new file[1000000];
    Thanks for all sugestions!

          * Download a file from a FTP server. A FTP URL is generated with the following syntax:
         * <code>ftp://user:password@host:port/filePath;type=i</code>.
          * @param ftpServer FTP server address (incl. optional port ':portNumber').
          * @param user Optional user name to login.
          * @param pwd Optional password for <i>user</i>.
          * @param fileName Name of file to download (with optional preceeding relative path, e.g. one/two/three.txt).
          * @param destination Destination file to save.
         * @throws MalformedURLException, IOException on error.
         public void download(String ftpServer, String user, String pwd, String fileName, File destination) throws MalformedURLException, IOException {
            if (ftpServer != null && fileName != null && destination != null) {
                StringBuffer sb = new StringBuffer("ftp://");
                if (user != null && pwd != null) { //need authentication?
                    sb.append(user);
                    sb.append(':');
                    sb.append(pwd);
                    sb.append('@');
                }//else: anonymous access
                sb.append(ftpServer);
                sb.append('/');
                sb.append(fileName);
                sb.append(";type=i"); //a=ASCII mode, i=image (binary) mode, d= file directory listing
                BufferedInputStream bis = null;
                BufferedOutputStream bos = null;
                try {
                    URL url = new URL(sb.toString());
                    URLConnection urlc = url.openConnection();
                    bis = new BufferedInputStream(urlc.getInputStream());
                    bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
                    int i;
                    while ((i = bis.read()) != -1) { //read next byte until end of stream
                        bos.write(i);
                    }//next byte
                } finally {
                    if (bis != null) try { bis.close(); } catch (IOException ioe) { /* ignore*/ }
                    if (bos != null) try { bos.close(); } catch (IOException ioe) { /* ignore*/ }
            }//else: input unavailable
        }//download()If you don't want to strore the data into a file, use ByteArrayOutputStream instead of a FileOutputStream.

  • How to Read file name which we are dealing with ODI File tool

    Hi,
    We are using ODi10g version and we have requirement to move file from one place to another place. We are using ODIFileMove utility but we also want to read file name.
    Any help.
    Thanks in Advance.

    You can accomplish this with a fairly simple Jython script.  Use the os.listdir(<directory>) command to get the name of files in a given directory. 
    You can then (still in the Jython script) loop through the files and move them to a desired location (bypassing the OdiFileMove tool) OR use the Jython script to write the file names to a SQL table.  Then, use an ODI procedure to loop through the newly inserted records and store the file name in an ODI variable that you can then use in your OdiFileMove tool etc.
    I often refer to this blog entry from Gurcan Orhan as a starting point for this kind of task: Loading multiple files with ODI | Gurcan Orhan&amp;#039;s Oracle Data Integrator Blog

  • How to read file in sync.?

    Hi all,
    I am using URLLoader to read file, but it has trouble/problem
    that is need to wait the load complete event to finish read file
    action. So i cannot use it to load file to read some configuration
    file to assign to the class variables.
    I want to use as follow:
    var config:ConfigFile = new ConfigFile();
    var file:String = "data.ini";
    config.Load(file);
    var x:int = config.X;
    var y:Strin = config.Y;
    If I use URLLoad that cannot implement to get properties
    directly, I need to wait complete event then I need to dispatch my
    own event again to tell the caller is allow to get properties.
    Anyone has other method to help me to implement these usage
    way?
    Thanks.

    Hi,
    Sync Read is an outbound operation, you can not use inbound configuration parameters for it.
    http://docs.oracle.com/cd/E17904_01/integration.1111/e10231/adptr_file.htm#CACHDJFF
    If you have a large file you may use ChunkedRead
    http://docs.oracle.com/cd/E17904_01/integration.1111/e10231/adptr_file.htm#BABJFCBH
    Cheers,
    Vlad
    Give points - it is good etiquette to reward an answerer points (5 - helpful; 10 - correct) for their post if they answer your question. If you think this is helpful, please consider giving points

  • PS Custom Format Plugin - Issue Reading Files 2GB & 4GB

    Is this issue fixable within our format plugin code, or is it  a photoshop limitation?
    I am new to Photoshop & Photoshop Plugins.  I have reviewed the sdk photoshop documentation & searched web on this subject.
    I am working with a photoshop format plugin written by my predecessor who is no longer here.
    The plugin is modeled after the simpleFormat plugin.
    The plugin is being used on systems running Photoshop CS6 & CC on 64bit Windows 7 with 8GB or more memory.
    The plugin allows a file of our format to be opened, read and written.
    ISSUE:
    The plugin works fine reading  files < 2GB or > 4GB.  For files between 2GB and 4GB, the call to allocate memory fails.
    In the plugin's PIPL structure:   the FormatMaxSize {32767, 32767} and PluginMaxSize {PlugInMaxSize { 2147483647, 2147483647 }
    In the plugin code;  the DoReadStart() method opens the file and reads the file header information.  This works fine.
    Next, in the DoReadContinue() method: SPsBuffer->New(&bufferSize, buffersize) is returning NULL.     see below.
    void PluginMain (const int16 selector,
                                                                             FormatRecordPtr formatParamBlock,
                                                                             intptr_t * data,
                                                                             int16 * result)
        gFormatRecord = reinterpret_cast<FormatRecordPtr>(formatParamBlock);
              gPluginRef = reinterpret_cast<SPPluginRef>(gFormatRecord->plugInRef);
              gResult = result;
              gDataHandle = data;
    sSPBasic = ((FormatRecordPtr)formatParamBlock)->sSPBasic;
    if (gCountResources == NULL ||
                gGetResources == NULL ||
                gAddResource == NULL ||
    gFormatRecord->advanceState == NULL)
    *gResult = errPlugInHostInsufficient;
    return;
    // new for Photoshop 8, big documents, rows and columns are now > 30000 pixels
    if (gFormatRecord->HostSupports32BitCoordinates)
            gFormatRecord->PluginUsing32BitCoordinates = true;
    static void DoReadPrepare()
         gFormatRecord->maxData = 0
    static void DoReadContinue (void)
              int32 done;
              int32 total;
              int32 row;
              VPoint imageSize = GetFormatImageSize();
              /* Set up the buffer & progress variables. */
              done = 0;
              total = imageSize.v;
        Ptr pixelData        = NULL;
        Ptr rawData          = NULL;
        Ptr uncompressedData = NULL;
        int64* offsetTable   = NULL;
    /* allocate the pixel buffer. */
              unsigned32 bufferSize = gFormatRecord->planes * imageSize.v * imageSize.h;
              pixelData = sPSBuffer->New( &bufferSize, bufferSize );            <======   This allocation fails for file sizes > 2GB & < 4GB.
              if (pixelData == NULL)
                        *gResult = memFullErr;
                        //return;
                        if(*gResult == memFullErr) { goto ReadContinueCleanUp; }

    Some examples of files that are successfully read and files that are not successfully read are shown below:
    Filenames that contain "nok" as part of the name, would not open and an out of RAM error occurs.
    in the ReadContinue method, shown in an earlier post on this thread.
    Filenames
    12x12ok
    12x24ok
    ok
    nok
    nok
    nok
    ok
    hdots
    17280
    17280
    23160
    23180
    30001
    32768
    32768
    vdots
    8640
    17280
    23160
    23180
    30001
    32768
    32768
    hdots * vdots
    149299200
    298598400
    536385600
    537312400
    900060001
    1.074E+09
    1.074E+09
    hdots  + vdots
    25920
    34560
    46320
    46360
    60002
    65536
    65536
    hdpi,vdpi
    1440:720
    1440:720
    1440:720
    1440:720
    1440:720
    1440:720
    1440:720
    #channels
    4
    4
    4
    4
    4
    4
    5
    #bpp
    2
    2
    2
    2
    2
    2
    2
    compression
    Packbits
    Packbits
    Packbits
    Packbits
    Packbits
    fileLength(bytes)
    8593776
    8647536
    14365054
    17063936
    21258240
    filesize (MB)
    356
    712
    8.19
    8.24
    13.7
    16.27
    20.27
    filesize (GB)
    0.348
    0.69
    0.008
    0.008
    0.0134
    0.016
    0.0198

  • FRM-10221: Cannot read file /u02/applfint/apps/apps_st/appl/au/12.0.0/resource  FRM-41810 FRM-41067

    Hello Experts,
    I am in the process upgrade EBS to 12.1.3 and when attempting to launch forms to "Generate All Business Views", I encountered three Form errors:
    FRM-10221: Cannot read file /u02/applfint/apps/apps_st/appl/au/12.0.0/resource
    FRM-41810: error creating menu
    FRM-41067: cannot fine menu item: invalid ID
    Back in my shell, I have also noticed that some part of my environment variable is not functioning correctly or is missing:
    . /u02/applfinp/apps/apps_st/appl/APPSOFPROD_ofinprod01.env
    or
    . /u02/applfinp/apps/apps_st/appl/OFPROD_ofinprod01.env
    Gives:
    -bash: /usrxit/devenv.env: No such file or directory
    I have used adadmin utility and choose option to recreate grants and synonyms; executing adautocfg.sh  but problem is persisting.
    Thanks
    Mathias

    Hello Hussein,
    I am glad you are online. I am on a deadline to finish an upgrade by 8 AM this morning.
    I have actually finished the upgrade and was about to "Generate All Business Views" to fix all the dozens of invalid views that are trailing.
    I had just finished applying Patch 9239090 to get to ebs 12.1.3 an its pre-requisits. This is the first time I am opening these forms and all forms are throwing the same error.
    I have manually relinked the adadmin:
    adrelink.sh force=y "ad adadmin"
    Autoconfig is giving errors:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 1
    java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 1
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
    Thanks
    Mathias

  • Read file gives java.lang.Nullpointer exception

    I am reading to read a ".txt" file created by "python code" and stored in my directory.
    If i comment the python code and store the file ("statusfile.txt') in the directory, the code is able to read the file. but when i uncomment and run the python code to generate the file ..it gives java.lang.NullPointerException.
    the two functions for reading the file and running the python code are separate but in the same class and are also called in one JSP. Does anyone have any suggestions.
    Someone did suggest me to use getResourceAsStream.. but i do not understand where to use it .. in the class (where i am doing the readfile function or where in the runpython function which basically generates the file) I did tried using it in JSP and also in the class.. but nothing seems to work. Also as i saw the examples.. getResourceAsStream is used for uploading properties or config files. I just want to simplying read the simpel text file which is already stored in the directory and return a boolean to JSP if reading file was a success.
    in short the algo is
    ON JSP:
    1) call class function to run python code
    2) call class function to read the generated in step 1.
    CLASS
    1) function runpython()
    // store generated files in the specified directory
    2) function readFile()
    //read file from specified directory
    //return boolean
    Any suggestions
    Thanx

    The problem is where is "your directory"?
    Creating a file by new File("myFile.txt") just puts it in the current working directory.
    Sometimes this is something like the bin directory.
    Most web applications use ServletContext.getRealPath("/")
    This turns a website relative reference into a file reference on the local machine.
    So you can say getRealPath("/index.html") and it will return the file (for example) C:\tomcat\webapps\root\index.html
    On to suggestions:
    Null pointer exception?
    Where is it coming from? Catch the exception and print a stack trace, to see if you can determine which line of code is causing it - which variable is null. Is it the actual file, or something you use to create the file?

  • HOW TO DELETE ADOBE READER FILE FROM ADOBE READER

    HOW TO DELETE ADOBE READER FILE FROM ADOBE READER@ !@

    Your question make no sense. What exactly are you trying to do?

  • Reading Files from an FTP location based on Timestamp

    Hi,
    I have a requirement of reading files from an FTP location. The files should be read in the order they were saved in the folder. Can someone tell me how to solve this?
    Thanks,
    Ravi

    Hi Arik,
    Thanks for your reply. I tried doing what u said, but it isn't working. My requirement is to List the files in the folder using FTP adapter and get the file name with the least file stamp from the FTP adapter and pass the FileName dynamically to another FTP adapter which reads the file based on the FileName. When i tested after including the property (for listing the files) you mentioned, it is giving the following error (copied from flow trace):
    <messages>
    <input>
    <Invoke_getFileListFTP_FileListing_InputVariable>
    <part name="Empty" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <empty xmlns="http://xmlns.oracle.com/pcbpel/adapter/ftp/APP_SequentialFileTransfer/PRJ_SequentialFileTransfer/WS_GetFileList_FTP"/>
    </part>
    </Invoke_getFileListFTP_FileListing_InputVariable>
    </input>
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
    <part name="summary">
    <summary>Exception occured when binding was invoked. Exception occured
    during invocation of JCA binding: "JCA Binding execute of
    Reference operation 'FileListing' failed due to: Exception
    occured when binding was invoked. Exception occured during
    invocation of JCA binding: "Could not instantiate
    InteractionSpec
    oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec due
    to: Cannot set JCA WSDL Property. Error while setting JCA
    WSDL Property. Property setListSorter is not defined for
    oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec Please
    verify the spelling of the property. ". The invoked JCA
    adapter raised a resource exception. Please examine the above
    error message carefully to determine a resolution. ". The
    invoked JCA adapter raised a resource exception. Please
    examine the above error message carefully to determine a
    resolution.</summary>
    </part>
    <part name="detail">
    <detail>Cannot set JCA WSDL Property. Error while setting JCA WSDL
    Property. Property setListSorter is not defined for
    oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec Please
    verify the spelling of the property.</detail>
    </part>
    <part name="code">
    <code>null</code>
    </part>
    </bindingFault>
    </bpelFault>
    </fault>
    <faultType>
    <message>0</message>
    </faultType>
    </messages>
    Thanks,
    Ravi
    Edited by: Ravi Santosh on Apr 24, 2012 11:02 PM

  • Reading file from a folder : File dir = new File(URL+aFile_to_add);

    Hi,
    Trying to read files from a dir on my site using a JSP and bean. I've tried nearly every option for the filepath I can think of and it doesn't seem to be finding the file...
    Here's the bit:
    String URL = "images\\wedding_photos\\";
    File dir = new File(URL+aFile_to_add);
    String[] files = dir.list();
    It's working locally, but I obviously had to change the path from c://... to the above.
    The full code is listed below in the addWedding Method
    The method removes the .jpg from the file name and then writes the new file name to a database
    Thanks for any insight.
    Regards
    Jim
    public String addWedding(String aFile_to_add)
    String feedback = "unset in scrubWedding";
    try
    String URL = "images\\wedding_photos\\";
    Class.forName("org.gjt.mm.mysql.Driver");
    java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/rhwedd2_shop?user=**********&password=*******");
    java.sql.Statement statement = connection.createStatement();
    File dir = new File(URL+aFile_to_add);
    String[] files = dir.list();
    if (files == null)
    feedback = "Sorry, couldn't find the file "+aFile_to_add+"...no files have been added.";
    else
    for (int i=0; i<files.length; i++)
    // Get filename of file or directory
    String filename = files;
    String no_extension;
    //convert string array element into a char array
    char [] charsfilename = filename.toCharArray();
    int newlength = charsfilename.length -4;
    no_extension = String.valueOf(charsfilename,0,newlength);
    filesAdded = filesAdded+", "+no_extension;
    // Show the new file names in stack trace without extension
    //System.out.println("String no_extension " + no_extension );
    statement.executeUpdate("INSERT INTO items VALUES ('"+no_extension+"',5,'"+aFile_to_add+"')");
    // write to table with item_id and weddingid
    feedback = "The following files have been added..."+filesAdded;
    if (statement != null )
    statement.close();
    if ( connection != null )
    connection.close();
    catch(Exception e)
    feedback = "Into the catch";
    e.printStackTrace(System.err) ;
    return feedback;
    }//end addWedding

    String URL = "images\\wedding_photos\\";
    File dir = new File(URL+aFile_to_add); ok, ok, I'll answer...
    1) What gives you the impression that the relative directory "images\\..." exists (or, in other words, what makes you think your current directory is the parent of "images"?

Maybe you are looking for

  • Purchase value report

    please tell me how to start. i want to know from which table to start for the following requirement. please tell all the steps. starting table and end table. Report for Purchase Details: Input Parameters: **Plant:           - -   to -    (Multiple op

  • SELECT is taking lot of time to fetch data from cluster table BSET

    <Modified the subject line> Hi experts, I want to fetch data of some fields from bset table but it is taking a lot of time as the table is cluster table. Can you please suggest me any other process to fetch data from cluster table. I am using native

  • Header text in form medruck

    hi gurus, i have a requirement to move the header text of the PO after the terms of payment. but in the standard form medruck the codes for header text are in the first line of the main window so it should be display first.but how this header text di

  • Need help for performance tunning

    Hello, I have 16K records return by query, it takes long time to proceed for 7K it takes 7.5 sec. Note: I used all seeded tables only. If possible please help me to tune it. SELECT       msi.inventory_item_id,msi.segment1,msi.rimary_uom_code , msi.pr

  • Load External URL in Container

    I want to have a page with my menu that pulls external urls and places it within some type of container on the same page. Is this possible? Every tut or example on the web that I seem to find can load urls either in a _blank or _top using the navigat