Help with Files

Hi,
I want to delete all the files inside a specific folder using java...
can anyone give me a solution regarding this

Hi,
I want to delete all the files inside a specific
folder using java...
can anyone give me a solution regarding thisHave a look at the File class:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html

Similar Messages

  • Need Help With File Matching Records

    I need help with my file matching program.
    Here is how it suppose to work: FileMatch class should contain methods to read oldmast.txt and trans.txt. When a match occurs (i.e., records with the same account number appear in both the master file and the transaction file), add the dollar amount in the transaction record to the current balance in the master record, and write the "newmast.txt" record. (Assume that purchases are indicated by positive amounts in the transaction file and payments by negative amounts.)
    When there is a master record for a particular account, but no corresponding transaction record, merely write the master record to "newmast.txt". When there is a transaction record, but no corresponding master record, print to a log file the message "Unmatched transaction record for account number ..." (fill in the account number from the transaction record). The log file should be a text file named "log.txt".
    Here is my following program code:
    // Exercise 14.8: CreateTextFile.java
    // creates a text file
    import java.io.FileNotFoundException;
    import java.lang.SecurityException;
    import java.util.Formatter;
    import java.util.FormatterClosedException;
    import java.util.NoSuchElementException;
    import java.util.Scanner;
    import org.egan.AccountRecord;
    import org.egan.TransactionRecord;
    public class CreateTextFile
      private Formatter output1;  // object used to output text to file
      private Formatter output2;  // object used to output text to file
      // enable user to open file
      public void openTransFile()
        try
          output1 = new Formatter("trans.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openTransFile
      // enable user to open file
      public void openOldMastFile()
        try
          output2 = new Formatter("oldmast.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openOldMastFile
      // add transaction records to file
      public void addTransactionRecords()
        // object to be written to file
        TransactionRecord record1 = new TransactionRecord();
        Scanner input1 = new Scanner(System.in);
        System.out.printf("%s\n%s\n%s\n%s\n\n",
          "To terminate input, type the end-of-file indicator",   
          "when you are prompted to enter input.",
          "On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
          "On Windows type <ctrl> z then press Enter");
        System.out.printf("%s\n%s",
           "Enter account number (> 0) and amount.","? ");
        while (input1.hasNext())  // loop until end-of-file indicator
          try // output values to file
            // retrieve data to be output
            record1.setAccount(input1.nextInt());    // read account number
            record1.setAmount(input1.nextDouble());  // read amount
            if (record1.getAccount() > 0)
              // write new record
              output1.format("%d %.2f\n", record1.getAccount(), record1.getAmount());
            } // end if
            else
              System.out.println("Account number must be greater than 0.");
            } // end else
          } // end try
          catch (FormatterClosedException formatterClosedException)
            System.err.println("Error writing to file.");
            return;
          } // end catch
          catch (NoSuchElementException elementException)
            System.err.println("Invalid input. Please try again.");
            input1.nextLine(); // discard input so user can try again
          } // end catch
          System.out.printf("%s %s\n%s", "Enter account number (> 0) ",
            "and amount.","? ");
        } // end while
      } // end method addTransactionRecords
      // add account records to file
      public void addAccountRecords()
        // object to be written to file
        AccountRecord record2 = new AccountRecord();
        Scanner input2 = new Scanner(System.in);
        System.out.printf("%s\n%s\n%s\n%s\n\n",
          "To terminate input, type the end-of-file indicator",   
          "when you are prompted to enter input.",
          "On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
          "On Windows type <ctrl> z then press Enter");
        System.out.printf("%s\n%s",
           "Enter account number (> 0), first name, last name and balance.","? ");
        while (input2.hasNext())  // loop until end-of-file indicator
          try // output values to file
            // retrieve data to be output
            record2.setAccount(input2.nextInt());    // read account number
            record2.setFirstName(input2.next());      // read first name
            record2.setLastName(input2.next());       // read last name
            record2.setBalance(input2.nextDouble());  // read balance
            if (record2.getAccount() > 0)
              // write new record
              output2.format("%d %s %s %.2f\n", record2.getAccount(), record2.getFirstName(),
                record2.getLastName(), record2.getBalance());
            } // end if
            else
              System.out.println("Account number must be greater than 0.");
            } // end else
          } // end try
          catch (FormatterClosedException formatterClosedException)
            System.err.println("Error writing to file.");
            return;
          } // end catch
          catch (NoSuchElementException elementException)
            System.err.println("Invalid input. Please try again.");
            input2.nextLine(); // discard input so user can try again
          } // end catch
          System.out.printf("%s %s\n%s", "Enter account number (> 0),",
            "first name, last name and balance.","? ");
        } // end while
      } // end method addAccountRecords
      // close file
      public void closeTransFile()
        if (output1 != null)
          output1.close();
      } // end method closeTransFile
      // close file
      public void closeOldMastFile()
        if (output2 != null)
          output2.close();
      } // end method closeOldMastFile
    } // end class CreateTextFile--------------------------------------------------------------------------------------------------
    // Exercise 14.8: CreateTextFileTest.java
    // Testing class CreateTextFile
    public class CreateTextFileTest
       // main method begins program execution
       public static void main( String args[] )
         CreateTextFile application = new CreateTextFile();
         application.openTransFile();
         application.addTransactionRecords();
         application.closeTransFile();
         application.openOldMastFile();
         application.addAccountRecords();
         application.closeOldMastFile();
       } // end main
    } // end class CreateTextFileTest-------------------------------------------------------------------------------------------------
    // Exercise 14.8: TransactionRecord.java
    // A class that represents on record of information
    package org.egan; // packaged for reuse
    public class TransactionRecord
      private int account;
      private double amount;
      // no-argument constructor calls other constructor with default values
      public TransactionRecord()
        this(0,0.0); // call two-argument constructor
      } // end no-argument AccountRecord constructor
      // initialize a record
      public TransactionRecord(int acct, double amt)
        setAccount(acct);
        setAmount(amt);
      } // end two-argument TransactionRecord constructor
      // set account number
      public void setAccount(int acct)
        account = acct;
      } // end method setAccount
      // get account number
      public int getAccount()
        return account;
      } // end method getAccount
      // set amount
      public void setAmount(double amt)
        amount = amt;
      } // end method setAmount
      // get amount
      public double getAmount()
        return amount;
      } // end method getAmount
    } // end class TransactionRecord -------------------------------------------------------------------------------------------------
    // Exercise 14.8: AccountRecord.java
    // A class that represents on record of information
    package org.egan; // packaged for reuse
    import org.egan.TransactionRecord;
    public class AccountRecord
      private int account;
      private String firstName;
      private String lastName;
      private double balance;
      // no-argument constructor calls other constructor with default values
      public AccountRecord()
        this(0,"","",0.0); // call four-argument constructor
      } // end no-argument AccountRecord constructor
      // initialize a record
      public AccountRecord(int acct, String first, String last, double bal)
        setAccount(acct);
        setFirstName(first);
        setLastName(last);
        setBalance(bal);
      } // end four-argument AccountRecord constructor
      // set account number
      public void setAccount(int acct)
        account = acct;
      } // end method setAccount
      // get account number
      public int getAccount()
        return account;
      } // end method getAccount
      // set first name
      public void setFirstName(String first)
        firstName = first;
      } // end method setFirstName
      // get first name
      public String getFirstName()
        return firstName;
      } // end method getFirstName
      // set last name
      public void setLastName(String last)
        lastName = last;
      } // end method setLastName
      // get last name
      public String getLastName()
        return lastName;
      } // end method getLastName
      // set balance
      public void setBalance(double bal)
        balance = bal;
      } // end method setBalance
      // get balance
      public double getBalance()
        return balance;
      } // end method getBalance
      // combine balance and amount
      public void combine(TransactionRecord record)
        balance = (getBalance() + record.getAmount()); 
      } // end method combine
    } // end class AccountRecord -------------------------------------------------------------------------------------------------
    // Exercise 14.8: FileMatch.java
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.lang.IllegalStateException;
    import java.util.NoSuchElementException;
    import java.util.Scanner;
    import java.util.Formatter;
    import java.util.FormatterClosedException;
    import org.egan.AccountRecord;
    import org.egan.TransactionRecord;
    public class FileMatch
      private Scanner inTransaction;
      private Scanner inOldMaster;
      private Formatter outNewMaster;
      private Formatter theLog;
      // enable user to open file
      public void openTransFile()
        try
          inTransaction = new Scanner(new File("trans.txt"));
        } // end try
        catch (FileNotFoundException fileNotFoundException)
          System.err.println("Error opening file.");
          System.exit(1);
        } // end catch
      } // end method openTransFile
      // enable user to open file
      public void openOldMastFile()
        try
          inOldMaster = new Scanner(new File("oldmast.txt"));
        } // end try
        catch (FileNotFoundException fileNotFoundException)
          System.err.println("Error opening file.");
          System.exit(1);
        } // end catch
      } // end method openOldMastFile
      // enable user to open file
      public void openNewMastFile()
        try
          outNewMaster = new Formatter("newmast.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openNewMastFile
      // enable user to open file
      public void openLogFile()
        try
          theLog = new Formatter("log.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openLogFile
      // update records
      public void updateRecords()
        TransactionRecord transaction = new TransactionRecord();
        AccountRecord account = new AccountRecord();
        try // read records from file using Scanner object
          System.out.println("Start file matching.");
          while (inTransaction.hasNext() && inOldMaster.hasNext())
            transaction.setAccount(inTransaction.nextInt());     // read account number
            transaction.setAmount(inTransaction.nextDouble());   // read amount
            account.setAccount(inOldMaster.nextInt());     // read account number
            account.setFirstName(inOldMaster.next());      // read first name 
            account.setLastName(inOldMaster.next());       // read last name
            account.setBalance(inOldMaster.nextDouble());  // read balance
            if (transaction.getAccount() == account.getAccount())
              while (inTransaction.hasNext() && transaction.getAccount() == account.getAccount())
                account.combine(transaction);
                outNewMaster.format("%d %s %s %.2f\n",
                account.getAccount(), account.getFirstName(), account.getLastName(),
                account.getBalance());
                transaction.setAccount(inTransaction.nextInt());     // read account number
                transaction.setAmount(inTransaction.nextDouble());   // read amount
            else if (transaction.getAccount() != account.getAccount())
              outNewMaster.format("%d %s %s %.2f\n",
              account.getAccount(), account.getFirstName(), account.getLastName(),
              account.getBalance());         
              theLog.format("%s%d","Unmatched transaction record for account number ",transaction.getAccount());
          } // end while
          System.out.println("Finish file matching.");
        } // end try
        catch (NoSuchElementException elementException)
          System.err.println("File improperly formed.");
          inTransaction.close();
          inOldMaster.close();
          System.exit(1);
        } // end catch
        catch (IllegalStateException stateException)
          System.err.println("Error reading from file.");
          System.exit(1);
        } // end catch   
      } // end method updateRecords
      // close file and terminate application
      public void closeTransFile()
        if (inTransaction != null)
          inTransaction.close();
      } // end method closeTransFile
      // close file and terminate application
      public void closeOldMastFile()
        if (inOldMaster != null)
          inOldMaster.close();
      } // end method closeOldMastFile
      // close file
      public void closeNewMastFile()
        if (outNewMaster != null)
          outNewMaster.close();
      } // end method closeNewMastFile
      // close file
      public void closeLogFile()
        if (theLog != null)
          theLog.close();
      } // end method closeLogFile
    } // end class FileMatch-------------------------------------------------------------------------------------------------
    // Exercise 14.8: FileMatchTest.java
    // Testing class FileMatch
    public class FileMatchTest
       // main method begins program execution
       public static void main( String args[] )
         FileMatch application = new FileMatch();
         application.openTransFile();
         application.openOldMastFile();
         application.openNewMastFile();
         application.openLogFile();
         application.updateRecords();
         application.closeLogFile();
         application.closeNewMastFile();
         application.closeOldMastFile();
         application.closeTransFile();
       } // end main
    } // end class FileMatchTest-------------------------------------------------------------------------------------------------
    Sample data for master file:
    Master file                         
    Account Number            Name                     Balance
    100                            Alan Jones                   348.17
    300                            Mary Smith                    27.19
    500                            Sam Sharp                   0.00
    700                            Suzy Green                   -14.22Sample data for transaction file:
    Transaction file                    Transaction
    Account Number                  Amount
    100                                         27.14
    300                                         62.11
    300                                         83.89
    400                                         100.56
    700                                         80.78
    700                                         1.53
    900                                         82.17  -------------------------------------------------------------------------------------------------
    My FileMatch class program above has bugs in it.
    The correct results for the newmast.txt:
    100  Alan  Jones  375.31
    300  Mary  Smith  173.19
    500  Sam  Sharp  0.00
    700  Suzy Green  68.09The correct results for the log.txt:
    Unmatched transaction record for account number 400Unmatched transaction record for account number 900------------------------------------------------------------------------------------------------
    My results for the newmast.txt:
    100 Alan Jones 375.31
    300 Mary Smith 111.08
    500 Sam Sharp 0.00
    700 Suzy Green -12.69My results for the log.txt
    Unmatched transaction record for account number 700-------------------------------------------------------------------------------------------------
    I am not sure what is wrong with my code above to make my results different from the correct results.
    Much help is appreciated. Please help.

    From the output, it looks like one problem is just formatting -- apparently you're including a newline in log entries and not using tabs for the newmast output file.
    As to why the numbers are off -- just from glancing over it, it appears that the problem is when you add multiple transaction values. Since account.combine() is so simple, I suspect that you're either adding creating transaction objects incorrectly or not creating them when you should be.
    Create test input data that isolates a single case of this (e.g., just the Mary Smith case), and then running your program in a debugger or adding debugging code to the add/combine method, so you can see what's happening in detail.
    Also I'd recommend reconsidering your design. It's a red flag if a class has a name with "Create" in it. Classes represent bundles of independant state and transformations on that state, not things to do.

  • Please help with File input!

    This is my first time dealing with file I/O and need help figuring out the best way to read in data and store it for further manipulation. I have a file that contains an individual's salary, and 3 product ratings on each line, such as: 75000 01 05 09
    What is the best way to store this data? I know how to use BufferedReader and how to tokenize each integer. I must write this program to deal with any number of lines in a file. There are three income brackets, and I must also be able to perform the following calculations:
    a) For each income bracket, the average rating for each product
    b) The number of persons in Income Bracket $50000-74000 that rates all three products with a score of 5 or higher.
    c) The average rating for Product 2 by persons who rated Product 1 lower than Prodcut 3.
    Thus far, I've written the following code to open the file and perform 2 reads to get the total number of lines (individuals) and the total number of inidividuals in each income bracket. It compiles, but I get a null pointed exception at StringTokenizer, for some reason.
    Please help! Do I need to take lines in as arrays? (tried this, but don't understand how to get at individual data) Do I need to somehow create objects for each person (if so, how?). My reference text covers this area poorly. Thanks for all help.
    import java.io.*;
    import java.util.*;
    public class Product_Survey
         public static void main(String [] args)
              int lineCount = 0;
              int inc1total = 0;
              int inc2total = 0;
              int inc3total = 0;
              String name = null;
              System.out.println("Please enter income and product info file name:  ");
              Scanner keyboard = new Scanner(System.in);
              name = keyboard.next();
              File fileObject = new File(name);
              while ((! fileObject.exists()) || ( ! fileObject.canRead()))
                   if( ! fileObject.exists())
                        System.out.println("No such file");
                   else
                        System.out.println("That file is not readable.");
                        System.out.println("Enter file name again:");
                        name = keyboard.next();
                        fileObject = new File(name);                    
              try
                   BufferedReader inputStream = new BufferedReader(new FileReader(name));
                   String trash = "No trash yet";
                   while (trash != null)
                        trash = inputStream.readLine();
                        lineCount++;
                   inputStream.close();
              catch(IOException e)
                   System.out.println("Problem reading from file.");
              try
                   BufferedReader inputStream = new BufferedReader(new FileReader(name));
                   String trash = "No trash yet";
                   while (trash != null)
                        trash = inputStream.readLine();
                        StringTokenizer st = new StringTokenizer(trash);
                        int income = Integer.parseInt(st.nextToken());
                        if(income<50000)
                             inc1total++;
                        else if(income<75000)
                             inc2total++;
                        else if(income<100000)
                             inc3total++;
                   inputStream.close();
              catch(IOException e)
                   System.out.println("Problem reading from file.");
    }

    Try adding a print statement to see what is happening in your second read loop:
                while (trash != null)
                    trash = inputStream.readLine();
                    System.out.println("trash = " + trash);
                    StringTokenizer st = new StringTokenizer(trash);Another way to read in a while loop:
                while ((trash = inputStream.readLine()) != null)

  • Help with file management

    Well I am just starting my first project using FCP and can see that it is going to be a learning curve after coming over from PPro.
    One thing that I have been unable to find is just how to keep track of which clips have been used in the timeline, and how many times. In Premiere Pro I had the option to show video and audio usage for each clip in the browser.
    Have not found how to do this yet in FCP.
    Hope someone can help with this....
    Thanks
    Kirk

    Guess that I just have to get used to how it is done in FCP. I have over 1,500 clips in about 30 folders and it would sure make it easy if I could just glance at a clip in the browser and see if it has been used.
    Thanks for the tip on the duplicate frames though. That is going to help to identify duplicate clips once they are placed in the timeline.
    Sure seems like a lot of time spent identifying if a clip is already used though. As I look through the clips in the browser I guess there is no way to tell if they have been used other than put them in the timeline or use the search function.
    Still learning here.
    Thanks
    Kirk

  • Help with File Upload manually

    Hi Experts,
    I need code to upload a file without using the upload UI Element. we have our terms and conditions which has to be signed by the user and once the user signs and clicks the next button to go to the next page, I generate a pdf with the time stamp of when the user signed and upload it to ECC. here i can not use the File upload UI Element but have to upload it automatically to ECC.
    Can any one help me out with this please.
    Thanks

    Hi,
    I dont know why you need to to upload the file for this requirement. You can simply store the user id and the timestamp in portal database table or in a ECC z table.
    In case you definitely need to upload the file then you can use KM API to uploadthe file to portal KM folder
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a099a3bd-17ef-2b10-e6ac-9c1ea42af0e9?quicklink=index&overridelayout=true
    but you need not use the upload feature in the example, instead just get the data from wd context and upload to KM.
    Srini

  • Need help with File to SOAP sync scenario: NO_BACK_SYSTEM_IN_HOPLIST

    Hello,
    I am setting up a new scenario where I get an XML file with PI, send that content via sync SOAP receiver call and direct the result of the web service response to SAP (just back to file as intermediate step).
    So far I have the transaction working to the SOAP adapter receiver request / response. I see the correct approval response coming in my SOAP channel (RWB AE payload), but this message gets stuck there before routing back to my receiver interface and mappings.
    General setup:
    FILE Sender to SYNC OB SI.
    OB SI Request is my source message type and Response is my final message output type.
    OM Source is this Sync OB SI. Target is a SOAP Sync IB SI. Request Mapping program matches the source file message type and target SOAP layout. Response Mapping matches SOAP response and Target is my final file layout.
    Routing for Sync OB SI ID uses this OM for Sync IB SI.
    SYNC IB SI has Request and REsponse messages mapping the external SOAP call.
    When I test the configuration I get success.
    When I send messages through I get error in the adapter about this NO_BACK_SYSTEM_IN_HOPLIST (therefore the response message is not making it back into the IE so that it can be mapped again and forwarded).
    Complete error message from RWB Adapter Log "Transmitting the message to endpoint http://[myhostname]:[myport]/sap/xi/engine?type=entry using connection SOAP_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: NO_BACK_SYSTEM_IN_HOPLIST:." and the next line is "Received XI System Error. ErrorCode: NO_BACK_SYSTEM_IN_HOPLIST ErrorText: null ErrorStack: Legacy system to which acknowledgment message is to be sent is missing in hoplist (with wasread=false)"
    Any ideas for me? (fyi not using BPM).
    Regards, Aaron Myers

    Hi AAron,
    Looks like this problem has occured before. There are SAP Notes recommended. Below are some helpful links.
    http://scn.sap.com/thread/848913
    http://scn.sap.com/message/4659941#4659941
    Thanks,
    Divya.

  • Help with Files in Java

    I need to replace some content in a file . Can some one tell me if we can append or replace only a part of the content in files using Java?
    Right now I am using Stringtokenizer, break the file into tokens and put them in a buffer, append the required data and then write to a file. But this seems very crude way of doing it and the output is not as I wanted it.
    Please help,
    Thanks

    "Random" updates to files are possible, but the problem lies when part of a file changes size, with the need to move the rest of it up or down. In general, when part of the file might change size, it's a lot easier all round to create a new version of the file and rename.

  • PHP disaster with entropy installation need help with file location

    I have a mac mini snow leopard server running 10.6.5 ,and I was trying to resolve a mcrypt module issue so that I could install wordpress and magento on some of our sites.After doing what I thought was extensive research, I decided to download the entropy php 5.30-3pkg from Marc Liyanage since it was already compiled and had an automatic install.I had the xcode tools installed and was going to attempt to compile it myself,but did not quite understand the instructions on Michael Gracie's site.When I installed the entropy package it told me that i needed to first disable the existing module,and I attempted to uncheck the php5 module,with no luck,as every time I tried to save it it rechecked itself,which I later discovered was happening because of dependency issues, as I had the mail,wiki,etc services on the sites checked. So my problem is that I wasn't aware at the time of the dependency issue,and I just renamed the module and the file name by putting a # in front of both (Inside the server admin dialog box through the pop up window).I didn't think it would hurt since is was going to be disabled,but now i get blank pages when trying to connect,and can't even see a test.php file, nor can I even locate where they say:
    software is supposed to be installed into a new directory /usr/local/php5 on my boot volume. If you ever want to get rid of the package, you only have to remove this directory and a symbolic link called +entropy-php.conf in either /etc/apache2/sites or /etc/apache2/other, depending on whether you run OS X Client or Server.
    Any help would be appreciated !

    Thank you so much, that works just like i wanted it to as it downloads the file but then i have the problem of the file being called firename.png (or whatever i put in there instead)
    using this i changed the code and made it this instead which works 100%
    set download to text returned of (display dialog "Enter IGN" default answer "" buttons {"Download", "Cancel"} default button 1)
    set the destination to (choose folder)
    do shell script "curl -L http://minecraft.net/skin/" & download & ".png" & " -o " & quoted form of ((POSIX path of the destination) & download & ".png")
    so i used the input name again with download and added a .png for the extention and now it downloads the file to the locaiton i specify with the name of the user im entering with the correct exention, 100% awesome ^^
    Thank you everyone who help me with that issue, grately appreshiated

  • Help with File.delete()

    Hi All!
    I am doing the following code:
    String indexPath = "Y:/var/session/ZGCoVyCCcooSl1uHRYCAWg.idx";
    File idxFile = new File(indexPath);
    if(idxFile.exists())
    System.out.println(indexPath + " exists.");
    else
    System.out.println(indexPath + " does not exist.");
    boolean idxDeleted = idxFile.delete();
    if(!idxDeleted)
    System.out.println("could not delete " + indexPath);
    if(idxFile.exists())
    System.out.println("failed to delete " + indexPath);
    When I run this code I get the following output:
    Y:/var/session/ZGCoVyCCcooSl1uHRYCAWg.idx exists.
    Which means that the file existed and the file is deleted. But, actually file is not deleted. When I try to manually delete the file, I get "sharing violation" error. I am running this code on a Windows 2000 server system and JDK1.4. I appreciate any help.
    thanks,
    Padma.

    That IS strange. I don't have a Win2K server to test on, but I know Win2K Pro (at a client's site) seems incredibly slow at a lot of things, like when working with WinExporer. Someone told me it had to do with a configuration option. Perhaps there is something in the config telling your server to defer file deletes, e.g. "lock" the (to be)deleted file so no one can access it, mark it for deletion, but defer until later during a lull when all pending deletes can be batched at once. That would explain why you can see it, but not access it, and it goes away after some time. Then again, I might be TOTALLY out in left field... :(

  • Help with File I/O Program

    hey guys. Just finished writing this program for fun and to test myself, because I just learned the File I/O chapter of a book that I bought in an attempt to teach myself java :). This program SHOULD take a users input and change it into binary form and then show them. Here is my code. It is to the best of MY ability. It compiles perfectly and works except for the fact that it doesnt show up in binary form. you will see once u compile it. there are two files, the main class and the methods class.
    Main Class:
    public class TextToBinaryChanger extends Methods
    public static void main(String args[])
    Methods.Greeting();
    Methods.WriteUserInputToFile();
    Methods.readFromUserInputFile();
    Methods.askIfExitProgram();
    here is the Methods Class:
    import javax.swing.*;
    import java.io.*;
    public class Methods
    public static void Greeting()
    JOptionPane.showMessageDialog(null,"Welcome to \"Binary Changer 1.0\"!");
    public static void WriteUserInputToFile()
    try
    DataOutputStream WriteUserInput = new DataOutputStream(new FileOutputStream("UserInput.dat"));
    PrintWriter WriteUserInputSave = new PrintWriter(new FileOutputStream("UserInputSave.txt"));
    String askUserForInput = JOptionPane.showInputDialog("Please enter in the text that you would like to have changed to binary form");
    JOptionPane.showMessageDialog(null, "The text you entered in was: " + askUserForInput);
    WriteUserInput.writeUTF(askUserForInput);
    WriteUserInput.close();
    catch (NullPointerException e)
    JOptionPane.showMessageDialog(null, "Null has been entered, ending program");
    System.exit(0);
    catch (FileNotFoundException e)
    JOptionPane.showMessageDialog(null, "This file was not found, ending program");
    System.exit(0);
    catch (IOException e)
    JOptionPane.showMessageDialog(null, "Error, program ending now");
    System.exit(0);
    public static void readFromUserInputFile()
    try
    DataInputStream showToUser = new DataInputStream(new FileInputStream("UserInput.dat"));
    BufferedReader showToUserSave = new BufferedReader(new FileReader("UserInputSave.txt"));
    JOptionPane.showMessageDialog(null, "You had first entered in:" + showToUserSave.readLine());
    JOptionPane.showMessageDialog(null, "Your text in Binary Form:" + showToUser.readUTF());
    showToUserSave.close();
    showToUser.close();
    catch (NullPointerException e)
    JOptionPane.showMessageDialog(null, "Null has been entered, ending program");
    System.exit(0);
    catch (FileNotFoundException e)
    JOptionPane.showMessageDialog(null, "This file was not found, ending program");
    System.exit(0);
    catch (IOException e)
    JOptionPane.showMessageDialog(null, "Error, program ending now");
    System.exit(0);
    public static void askIfExitProgram()
    String askUserIfExit = JOptionPane.showInputDialog("To run this program again, please enter in 'yes'. To exit enter in 'no'");
    try
    if (askUserIfExit.equalsIgnoreCase("yes"))
    WriteUserInputToFile();
    else
    JOptionPane.showMessageDialog(null, "Thank you for using Binary Changer 1.0!");
    System.exit(0);
    catch (NullPointerException e)
    JOptionPane.showMessageDialog(null, "Null has been entered, ending program");
    System.exit(0);
    Any help is very much appreciated. laterz,
    Lance

    // public because it doesn't matter
    // static because it doesn't depend on any instance variables (just trust me)
    // It will return a String representating the binary form of the data
    // takes a String parameter
    public static String toBinary(String data)
        // initialise a blank string to append to
        String toReturn = "";
        // we want to loop through each char of the string data
        for(int i=0;i<data.length();i++)
            // this line is complex
            // start from the right, and work left.
            // 1 - data.charAt(i)
            // this returns the char at index i in the string data
            // 2 - (int)data.charAt(i)
            // cast the char as an int so we can convert using existing methods
            // 3 - Integer.toBinaryString((int)data.charAt(i))
            // convert that int into a binary string
            String binary = Integer.toBinaryString((int)data.charAt(i));
            // say we converted the int 5, the string we got back would be "1001"
            // but I know that a char is 16bit, so I want to pad the start of it with zeroes
            // so while the string is shorted than 16, add a 0 to the start
            while(binary.length()<16)
                binary = "0" + binary;
            // add this onto our string that we will return
            // as well as a space so that it looks slightly formatted
            toReturn += binary + " ";
        return toReturn;
    }Understand?
    Cheers,
    Radish21

  • Newbie Help With File Parser

    I have an assignment that involves using Java to parse the info on one text file and output to another text file with a header row and a data row both of which need to be tab delimited. I'm relatively new to Java and I'm having a hard time even starting this thing. Any help would be greatly appreciated. The file I have to read from is similar to this:
    Report: Fake Report for Fake Loans
    Report ID: 000001
    Run Date: 04/25/2007
    Office Number ID Number DelqMessage
    033 000101000 N
    034 001234875 Y
    035 123456789 N
    I would essentially need to get all the field names into the header row and the data in the row below it.
    Thanks in advance.

    I have been working on this and I almost have it working correctly. I was able to selectively pull the info I need from the original file and I can output to the new file in a vertical form. The last step is to output a header that says RunDate Office Loan DelqMessage with a tab delimiter. I than have to compile the data and output in rows under the header also in tab delimited format. I think I'm right there but I still get one error I cannot resolve of:
    Error: java.lang.StringIndexOutOfBoundsException: String index out of range: 4
    It is very vague and I have tried everything I can think of to locate the issue so it can be debugged. Below is a copy of the file I'm trying to parse followed by what I have for code so far. Any help would be greatly appreciated.
    Sample of report:
    Report: Fake Report for Fake Loans
    Report ID: 000001
    Run Date: 04/25/2007
    ASC Number Loan ID DelqMessage
    033 000101000 N
    034 001234875 Y
    035 123456789 N
    ASC Number Loan ID DelqMessage
    036 741258963 N
    037 872563987 N
    038 987521455 Y
    ======================================================================
    Fake Report Summary:
    ASC Total: 6
    Loan Total: 6
    Total Delq: 2
    Code:
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.BufferedReader;
    import java.io.PrintWriter;
    import java.io.IOException;
    public class ParseFile {
    public static void main(String[] args) throws IOException {
         // Variable Declaration
         boolean procOn;
         String RunDate = "";
         BufferedReader inputStream = null;
    PrintWriter outputStream = null;
         // Following block of code parses FakeReportToParse.txt and outputs
         // needed portions of the report to characteroutput.txt
    try {
         procOn=false;
         inputStream =
    new BufferedReader(new FileReader("FakeReportToParse.txt"));
    outputStream =
    new PrintWriter(new FileWriter("characteroutput.txt"));
    String l;
    while ((l = inputStream.readLine()) != null) {
         outputStream.println("Rundate\tASCNumber\tLoan\tDelqMessage");
         if (l.indexOf("Run Date:")>=0) {
              RunDate = l.substring(10);
              outputStream.println(RunDate);
         // Processing of report data
         if(l.indexOf("ASC Number Loan ID") >= 0) {
              procOn = true;
         if(l.indexOf("-------------------------") >= 0 || l.indexOf("===============================") >= 0) {
              procOn = false;
         // Output report data to new characteroutput.txt file
         if(procOn) {
              String ASC = l.substring(0, 4).trim();
              String LoanID = l.substring(15, 25).trim();
              String DelqM = l.substring(30).trim();
         outputStream.println(RunDate + "\t" + ASC + "\t" + LoanID + "\t" + DelqM);
         catch(Exception z){
    System.out.println("Error: " + z.toString());
    }

  • Need help with File system creation fro Oracle DB installation

    Hello,
    I am new to Solaris/Unix system landscape. I have a Sun enterprise 450 with 18GB hard drive. It has Solaris 9 on it and no other software at this time. I am planning on adding 2 more hard drives 18gb and 36gb to accommodate Oracle DB.
    Recently I went through the Solaris Intermediate Sys admin training, knows the basic stuff but not fully confident to carry out the task on my own.
    I would appreciate some one can help me with the sequence of steps that I need perform to
    1. recognize the new hard drives in the system,
    2. format,
    3. partition. What is the normal strategy for partitioning? My current thinking is to have 36+18gb drives as data drives. This is where I am little bit lost. Can I make a entire 36GB drive as 1 slice for data, I am not quite sure how this is done in the real life, need your help.
    4. creating the file system to store the database files.
    Any help would be appreciated.

    Hello,
    Here is the rough idea for HA from my experience.
    The important thing is that the binaries required to run SAP
    are to be accessible before and after switchover.
    In terms of this file system doesn't matter.
    But SAP may recommend certain filesystem on linux
    please refer to SAP installation guide.
    I always use reiserfs or ext3fs.
    For soft link I recommend you to refer SAP installation guide.
    In your configuration the files related to SCS and DB is the key.
    Again those files are to be accessible both from hostA and from hostB.
    Easiest way is to use share these files like NFS or other shared file system
    so that both nodes can access to these files.
    And let the clustering software do mount and unmount those directory.
    DB binaries, data and log are to be placed in shared storage subsystem.
    (ex. /oracle/*)
    SAP binaries, profiles and so on to be placed in shared storage as well.
    (ex. /sapmnt/*)
    You may want to place the binaries into local disk to make sure the binaries
    are always accessible on OS level, even in the connection to storage subsystem
    losts.
    In this case you have to sync the binaries on both nodes manually.
    Easiest way is just put on shared storage and mount them!
    Furthermore you can use sapcpe function to sync necessary binaries
    from /sapmnt to /usr/sap/<SID>.
    For your last question /sapmnt should be located in storage subsystem
    and not let the storage down!

  • Noob Needs Help with File Size

    I created a simple form with no graphics, fonts are not embedded, and I selected the file to be filled out, printed, then mailed. The file size is 21MB. The form is to be emailed so it must be much smaller in size. Once received, the user will fill it out electronicly, print the form, then mail it back to me regular postal mail. Why is the file size so large and how can I make it smaller? Thanks in advance.
    Kevin

    OK. Here's what I did:
    1. At the welcome screen I selected "New Form" and then "New Blank Form"
    2. For the page size I left it at "Default" which is 8.5 x 11.
    3. For Return Method I selected "Fill then Print".
    4. At the last screen I just clicked "OK".
    5. Then I built the form. I put in (9) Text boxes, (4) Text Fields that look like Sunken Boxes, (5) Numeric Fields that look like Sunken Boxes, and (3) Check Boxes that look like Sunken Boxes.
    6. I then saved the file as a Static PDF Form File.
    7. The file size is 22.5 MB.
    That was my second attempt. The first attempt I had the fonts embedded and I had a Logo on the form. The file size for that one was 27.3 MB.
    Thanks for the help.
    Kevin

  • I need help with File Object in Java

    Hello Experts.
    I am learning Java 2 now. I have trouble with reading a JTextField and save it to a file. I have some errors that I dont know what they are. I would like someone please help me to write a short sample program to see how it work. The code from the book I have dont execute at all. And I want to use FileOutputStream and ObjectOutputStream. Thank you very much
    Quoc

    import java.io.*;
    public class FileTest {
      public static void main(String[] arg) throws Exception{
        FileOutputStream fileOut = new FileOutputStream("test.txt");
        fileOut.write("Test file".getBytes());
        fileOut.close();

  • HELP with File I/O + timerclass

    Hi,
    Background: I have one number in the text file that changes every X seconds.
    I'm trying to writing a program that periodically reads that text file and stores it in an array. Then writing this array to another text output file. I also want it to be compatible with the swing package.
    Problem:
    I know how to read the input file and know how to write the output file periodically, BUT I'm having problems with the index pointer when storing each sucessive values into an array. Java won't seem to let me implement a counter to keep track of the index within the timer class. That is I get some "static" error message. HELP any sugesstions around this? Here is my code:import java.util.*;
    //import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    // The "Ttest" class.
    public class Ttest3
        public double [] myArray = new double [24]; // array of 24 elemetns
        public int i = 0; //index of array
        public static void FileINCOPY ()
            String block; //fileINPUT CODE START
            FileInputStream in2; // declare a file input object
            FileOutputStream out; // declare a file output object
            PrintStream p; // declare a print stream object
            double converted;
            double value;
            double writeout;
            try
                // Create a new file input stream
                // connected to "Reading1.txt"
                in2 = new FileInputStream ("Reading1.txt");
                DataInputStream in =
                    new DataInputStream (in2);
                // Connect print stream to the input stream
                System.out.println ("Input from Reading1.txt is:");
                block = in.readLine ();
                converted = Double.parseDouble (block);
                myArray = converted;
    System.out.println (converted);
    in.close ();
    out = new FileOutputStream ("Reading2.txt");
    writeout = converted + 1;
    // Connect print stream to the output stream
    p = new PrintStream (out);
    p.println (writeout);
    // p.println ("This is written to a file");
    System.out.println (writeout);
    p.close ();
    i = i + 1; // incrementing index
    catch (Exception e)
    System.err.println ("Error opening to file");
    } // FILE INPUT END CODE HERE
    public static void main (String [] args)
    int counter = 0;
    int delay = 3000; // delay for 3 sec.
    int period = 3000; // repeat 3 every sec.
    Timer timer = new Timer ();
    System.out.println ("outside");
    timer.scheduleAtFixedRate (new TimerTask ()
    public void run ()
    FileINCOPY (); // reads a file and copies the value into another file
    // Task here ...
    , delay, period);
    System.out.println ("after");
    } // main method
    } // Ttest2 class
    Thanks

    You don't get "some 'static' error message". You get a particular error message with a precise meaning. You must read those error messages to find out what's wrong. Error messages are there to help you. Use them.
    Anyway the problem is that you're writing your program just with static methods, but you're referring to instance fields. Either make those fields static, or better yet refactor your program so that it's actually object-oriented (and you have objects encapsulating the state and behavior of various parts of your program).

  • CS2 - Help with file size.  "emptyfile.ai"  is saving with a size of 1.2 MB

    When we save a newly created file in illustrator CS 2 using Mac OS 10.4.11 the file is saved and the size is 1.2 MB.  The file contains one letter (character "A").  Can any tell me what settings I need to change to save this file with an approriate  size.
    Thanks for any help
    Glenn

    Run the Delete Unused Panel Items action. I already did this on all my new document profiles, so there are never any extraneous panel items in my new files. A new file created from Basic CMYK, with an A type in Myriad Pro Regular is 66 kB when saved without colour profile or PDF compatibility.
    But what is the problem? Surely the fact that a working, editable file is 1 MB is not a problem, so what it?

Maybe you are looking for

  • IPhone was charging, came to check on it, screen went black, turned it on, went to apple logo, then went black again!!!!!

    So i bought an iPhone 3g 16gb off of craigslist for 120. I met the person at safeway, where she showed me that the phone worked perfectly. She showed me a game, then exited and called my cell phone. I was sold. Before i leave she starts the restore p

  • Work Flow Notification mailer

    Hello Team: We have enabled work flow notification mailer service in our EBS system. Last week I restarted the services ( ALL Tiers ) and as soon as I did the restart. The business users started to receive Notification mailers. Apparently a bunch of

  • The search box and non-US english characters?

    Anyone know how to make the search box work right with non-US characters? For example lets say I wanted to search for an U with an umlaut (Sütterlin). If I type the ü it gives me every word with a U in it.

  • Best way of filtering records in a block

    Hi, i have a form with a data block that i want to filter. when i launch the form all records are fetched but then i want to choose the records displayed base on some criteria. Can i apply this criteria to the block so that it is not necessary to req

  • Canon multifunction cups recognized the printer but doesn't print

    i've a canon i-sensys MF4120 multifunction printer that don't won't to print on archlinux 64 bit. I've installed cups, compiled and installed the driver for the printer from AUR (cndrvcups-common and ufr2), started cups an added the printer, but when