Formating with Zero data Out takes 18 days..?!

I want to format my iMac with zero out data, but it takes 18 days for a 500Gb HD.
(I'm not even going to comment on the 35-pass format)
Now this is obviously ridiculous, and i'm now trying to decide if it's worth waiting,
or do I just smash the screen with a sledgehammer right away.  The iMac started
getting slower and slower everyday a few months ago, and now it takes an average
of 49 minutes to load google.com.  Way to go!   I've had it for 5 years now.
I browsed a lot but can't find any solution.  Any Ideas?

Just Re-partition and format then reinstall the OS. If it is still slow then you have a hardware problem. More then likely the drive is failing, Replace it.

Similar Messages

  • How do I sync my old iPhone 5 to a new laptop PC without losing any iPhone data? The "remove and sync?" option looks like it will leave me with zero data on the iPhone!

    how do I sync my iPhone 5 to a new Toshiba laptop PC without losing any iPhone data? The "remove and sync?" option looks like it will leave me with zero data on the iPhone!

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Conditional format with large data fails and show error as "Selection is too large" in Excel 2007

    I am facing a issue in paste special operation using conditional formats for large data in Excel 2007
    I have uploaded a file at below given location. 
    http://sdrv.ms/1fYC9qE
    The file contains two sheets, Sheet "Data" contains the data on which formats are to be applied and sheet "FormatTables" contains the format tables which contains conditional formating.
    There are two table in "FormatTables" sheet. Both have some conditional formats applied on it. 
    Case 1: 
    1. Select the table range of Table1 i.e $A$2:$AV$2
    2. Copy it
    3. Goto Sheet "Data" 
    4. Select data area i.e $A$1:$AV$20664
    5. Perform a paste special operation on full range and select "Formats" option while performing paste special.
    Result:
    It throws error as "Selection is too large"
    Case 2:
    1. Select the table range of Table2 i.e $A$5:$AV$5
    2. Copy it
    3. Goto Sheet "Data" 
    4. Select data area i.e $A$1:$AV$20664
    5. Perform a paste special operation on full range and select "Formats" option while performing paste special.
    Result:
    Formats get applied successfully.
    Both are the same format tables with same no of column and applied to same data range($A$1:$AV$20664) where one of the case works and another fails.
    The only diffrence is Table1 has appliesTo range($A$2:$T$2) as partial of total table range($A$2:$AV$2) whereas the Table2 has appliesTo range($A$5:$AV$5) same as of its total table range($A$5:$AV$5)
    NOTE : This issue is only in Excel 2007

    Excel 2007 No Supporting formating to take a formatting form another if source table has more then 16000 rows and if you want to do that in more then it then you have ot inset 1 more row in your format table to have 3 rows
    like: A1:AV3
    then try to copy that formating and apply
    Solution Case 1: 
    1.Select the table range of Table1 i.e AV21 and drage it down to one row down
    2. Select the table range of Table1 i.e $A$2:$AV$3
    3. Copy it
    4. Goto Sheet "Data" 
    5. Select data area i.e $A$1:$AV$20664
    6. Perform a paste special operation on full range and select "Formats" option while performing paste special

  • Strugging with exporting data out from an Unicode database

    Background information
    Server: Sun Solaris 5.10; 10g
    Client: Windows 2000; 10g, TOAD, Oracle ODBC 10.2.0.1
    select * from v$NLS_PARAMETERS
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_CHARACTERSET AL32UTF8
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    We import SAS data (Windows Latin character set) into Oracle, use OWB for ETL, export the results to SAS. Per regulatory requirements, character columns cannot exceed 200 in length.
    Problem scenario
    Data that cause the trouble (200 characters, with a degree sign at the 77th position):
    XXX PT PRIOR TO MSFC NOT TO USE WALKER, PT STATED SHE NEEDED IT LAST VISIT 2° BAD HEADACHE DECREASED BALANCE, WHICH WAS LATER FOUND TO BE SINUS INFECTION. ASKED PT NOT TO USE WALKER THIS TIME, PT SAID
    Degree sign is U+00B0 in UTF-8, or 0xB0 (176) in ASCII. Though, I found out select ascii('°') from dual would return 49480 (or, 0xC2 0xB0).
    In order to accommodate the import, Source.COMMENTX is VARCHAR2(201). Using OWB, we are mapping this to Target.COVAL which is VARCHAR2(200).
    To get around ORA-12899: value too large for column, we use the expression convert(Source.COMMENTX, 'WE8ISO8859P1', 'AL32UTF8')).
    Although viewing Target.COVAL shows a ¿ (true in TOAD, SQL*Plus), dump(COVAL) confirms the 77th character is 176:
    DUMP(COVAL)
    Typ=1 Len=200: [...],32,50,176,32,[...]
    Desirable outcome
    Store and display the text in a VARCHAR2(200) column without compromising the high-bit ASCII characters, e.g., degree sign, micro sign (i.e., Greek character mu), copyright sign, etc.
    Questions
    1. Is it a wrong assumption that AL32UTF8 supports the high-bit ASCII characters (i.e., characters between 128 and 255)? If not, why do the clients display the inverted question mark instead of degree sign when executing select chr(176) from dual?
    2. The aforementioned DUMP statement seems to confirm ASCII 0xB0 (i.e., not 0xC2 0xB0, or 0xBF) is being stored in the database at the 77th position. Why do my applications via ODBC interpreted and replaced it as 0xBF, which is the inverted question mark?
    Avenues attempted without the desirable outcome
    1. Changing Target.COVAL from VARCHAR2(200) to NVARCHAR2(200) or VARCHAR2(200 CHAR) would make SAS (data access through ODBC) think the length is 400 or 800, respectively [Note: The vendor claims it is ODBC 3.0 compliant]
    2. Through Microsoft's ODBC Test software, this is the output for describe column all against select COLVAL from Target:
    icol, szColName, pcbColName, pfSqlType, pcbColDef, pibScale, *pfNullable
    1, COMMENTX, 8, SQL_WVARCHAR=-9, 200, 0, SQL_NULLABLE=1

    Degree sign is U+00B0 in UTF-8, or 0xB0 (176) in
    ASCII. Though, I found out select ascii('°') from
    dual would return 49480 (or, 0xC2 0xB0).Well, U+00B0 represents 'degree sign' in Unicode, and the UTF-8 encoded value for this code point is C2 B0. ASCII does not include a degree sign, and 176 is not a ASCII code value (only 0-127). The function ascii will just return the decimal form of the encoded value, in the character set of the database (not necessarily ASCII, or US7ASCII as it is called in Oracle).
    >
    To get around ORA-12899: value too large for column,
    we use the expression convert(Source.COMMENTX,
    'WE8ISO8859P1', 'AL32UTF8')).This part I don't understand. And where are you storing this? In the same AL32UTF8 database? I think this might be your problem.
    >
    Although viewing Target.COVAL shows a ¿ (true in
    TOAD, SQL*Plus), dump(COVAL) confirms the 77th
    character is 176:Yes, since 176 is an invalid value in UTF-8. U+0079 is encoded as 79, U+0080 is encoded as C2 80 - notice the "leap" there. If I would input 176 in a "utf-8 decode" I would get "out of range" or NaN back. Similarily, if you have managed to illegally store 176 as a character encoded value in a AL32UTF8 database, and are trying to retrieve that, involving a conversion to client character set, you would get the replacement character ¿ meaning "bad conversion".
    >
    DUMP(COVAL)
    Typ=1 Len=200: [...],32,50,176,32,[...]
    Try
    select chr(49480) from dual;
    - but you need to do this from a tool such as Oracle SQL Developer (it's free) that can handle Unicode ouput.

  • BEx Analyzer: Display values with Zero data

    Hi,
    I urgently need to know something about BEx QD/Analyzer:
    If I drilldown e.g. Customer into the rows, it only shows me those customers for which there are values in place. However, I need to see all Customers, i.e. also the ones where the values are zero.
    How can I do this in Bex Analyzer or if needed BEx QD.
    Thanks
    Sabine

    Thanks,
    but it won't be possible to create a multiprovider just for that.
    Maybe I wasn't clear enough
    If a have Customer A, Cust B and Cust C and I drilldown by customer in the rows, then the system only shows me Cust B and Cust C, because for a there has been e.g. no turnover in one specific month.
    But in the drilldown in the report, I still want to see Cust A as well, even though the value is zero. So I should just see an empty line (instead of the key figures for Cust A).
    Guys, that must be possible!! Help me
    Sabine

  • Conditonal formatting with expiration date dependant on dropdown menu selection

    Hello all,
    I've got an interesting one for you.
    I'm creating a report tracking excel spreadsheet. I have to suspense the return of the report. That being said I want to find a way that I can have the row turn red if the suspense date is past but only if the another cell does not have a specific selection
    from a drop down menu selected.
    Specifics:
    J2 starts the column for the suspense date. G2 Starts the Drop down list. If the G2 (drop down) has anything selected other than "Complete" The row should be red. Once "Compete" is selected the rule should now longer be employed.

    Thanks for the quick reply George. Sorry for the confusion. Suspense is the military term we use. Basically, I send a report to someone and they are required to get it back to me by the suspense date (or due date). Its just the date in which they are required
    to send the report back to me. Until it is returned, the report is still "in suspense." That is why once the "Complete" is selected in G2 form the drop down list, I woul dlike the rule to no longer be applied. Does that answer/clarify your
    question?
    Thanks again Jeremy

  • Erase with Zero Out: Takes too long!

    So I've just bought a Seagate 400GB External USB2 HD. Connected it to the mac via USB and opened Disc Utility > Erase > Format to Mac Journaled Format with Zero Out.
    It takes ages....:eek: Its been running for over 2hrs. Is this normal
    I've got Panther Mac OS 10.3.9

    I was just worried because I started it aroun 6pm and it was still going like half way through arounf midnight. So I left it running all night so I can tell when it finished but I do know it is more the 6hrs at least.
    I would say 12hrs.
    for a 400GB drive at USB2 is that normal? it was FAT32 before so I set it for HFS+ with simgle pass

  • Query To update a date column with a date of my interest

    All,
    How to update a column in a table which is in date format with a date of my interest??
    Pls suggest.

    Please detail :
    1. what exactly you are trying to do
    2. what exactly you have done
    Nicolas.

  • Idoc with dummy data

    Dear All,
    Can you please send to me an Idoc (xml format) with dummy data for one of the following masterdata (MATMAS05, CREMDM04, DEBMDM06 ...) because I have MDM but I do not have any backend system (R/3, CRM..)
    My email addres is [email protected]
    Points will be awarded.
    Kind regards,
    NL

    Hi,
    one more delivered
    did you get this one too?
    Regards,
    Michal

  • Display dates with zeros for month, day, year.

    I have a date coming from a database as an int (20021215 means 12/15/2002). If the database gives me a "0", meaning no date value is assigned, then it should be displayed as "00/00/0000". The following code snippet works for the non-zero int database values ...
    public static String formatDisplayDate(int date) {
        String dateAsString = null;
        if (date == 0) {
            dateAsString = "00000000";
        else {
            dateAsString = Integer.toString(date);
        String strYear = dateAsString.substring(0,4);
        String strMonth = dateAsString.substring(4,6);
        String strDay = dateAsString.substring(6);
        int year = Integer.parseInt(strYear);
        int month = (Integer.parseInt(strMonth)) - 1;
        int day = Integer.parseInt(strDay);
        DateFormat myFormat = DateFormat.getDateInstance(DateFormat.SHORT);
        Calendar cal = myFormat.getCalendar();
        cal.set(year, month, day);
        Date myDate = cal.getTime();
        String formattedDate = myFormat.format(myDate);
        return formattedDate;
    }Although I didn't really expect the zero values case to work, I am not sure how to implement it. How would I go about building a string using all zeros and still have it automatically display in the correct locale format?
    Any help is appreciated.

    Thank you for your response. I agree a blank field would be better, but I think the "zeros" format is there to give the user an idea of expected date entry formatting, not that they'll necessarily follow it. I have made a few changes per your suggestions (shown below for the record, minus the exception handling), and it works perfectly.
    public static String formatExternalDate8(int date) {
      String dateAsString = null;
      if (date == 0) {
        dateAsString = "00010101";
      else {
        dateAsString = Integer.toString(date);
      int year = Integer.parseInt(dateAsString.substring(0,4));
      int month = (Integer.parseInt(dateAsString.substring(4,6))) - 1;
      int day = Integer.parseInt(dateAsString.substring(6));
      DateFormat myFormat = DateFormat.getDateInstance(DateFormat.SHORT);
      Calendar cal = myFormat.getCalendar();
      cal.set(year, month, day);
      Date myDate = cal.getTime();
      String formattedDate = myFormat.format(myDate);
      if (date == 0) {
        formattedDate = formattedDate.replace('1', '0');
      return formattedDate;
    }Thanks again for your assistance.

  • Figure out dates corresponding to days of the week, constructing a schedule

    Hi everyone,
    I'm sorry if this topic has already been covered. I've searched the forums for an answer, but did not see anything I took to be an answer (I'm not very good at this).
    I'm trying to make a simple table to tell me which dates a particular day of the week falls on. For instance, I'm making a syllabus for a class that meets every Tuesday and Thursday. I want to know which dates corresponds to every Tuesday and Thursday from here on out.
    I currently have a table with two columns. The first column is the day of the week. The first row is Tuesday, the second is Thursday, the third Tuesday, etc. I was able to do this easily with auto fill. I want the next column to be the date.
    Here's a picture of what I mean:
    Is there a formula that will let me do this?
    Thanks!

    Hi Macademic,
    How about putting both into the first column?
    Select all of column A and use the Cell Format inspector to set the format as Date and Time, with the Date: and Time: pop-up menus set to:
    Date: Mon, Jan 5, 2009
        or: Monday, January 5, 2009
        or  to a Custom format, Date and Time, including only the elements you want in the format you want them.
    Time: None
    Enter the starting date into A2, and confirm that it is either a Tuesday or a Thursday.
    In A3, enter
    =A2+2 (if the course starts on a Tuesday)
    or
    =A2+5 (if the course starts on a Thursday)
    In A4, enter
    =A2+7
    Select A3 and A4, then grab the control (small circle at the lower right corner of the selection) and drag down until you reach the last date of the course.
    Regards,
    Barry

  • Fastest way to extract data out of xml with following constraints.

    10.2 on linux
    xml files are being dropped off into a queue. in the queue the documents must be stored as clobs so that control can be given back to the client as soon as possible.
    once in the queue we would like to extract all the data from the xml and place it in relational staging tables. the data is then moved from these tables into production.
    the only thing that can change is what happens between the queue and the staging tables. currently i am just using extract statements to pull the data out of the clob.
    the files are around 20mb and currently take over 20 minutes to process which is way too long.
    i looked at DBMS_XMLSTORE but we cannot alter the xml format.
    i looked at Oracle text but if i understand it correctly, we would have to rebuild the entire index after every new queue item.
    i have very little experience with xml so i want to make sure i know all my options.
    from what i can tell my only option is to take the clob and let xml db parse it into o-r tables. ...but even that seems like a horrible waste.
    is there anything else i can do? any pointers?
    thanks for any help!
    by the way...this forum has been of great help. my only problem is that i don't seem to ask the right questions at the right time.

    Chris
    Most people seem to find that allow XML DB to persist the XML using the object based storage and nested tables and then using insert as select operations is the most effective way to do what you want. There are a number of threads on how to best do this..
    The question to ask is do you really need the relational staging tables. If you read through the forum you'll see that once the XML has been persisted as objects, and the XML objects have been stored using a nested table storage models you can easily create relational views to represent the staging tables.
    This process will work very well if there are no updates to the staging tables. Effectively you will process the XML once, when you insert into the Schema based tables, and then use the relational views as the source for the migration from staging to production.
    If you haven't already done so, reading the following posts will help you with this
    XMLType column based on XML Schema: several questions
    http://forums.oracle.com/forums/thread.jspa?threadID=347820&tstart=0
    problem with sql/xml
    XML Query Performance on Nested Tables
    Basically you'll need an XML Schema that describes your XML and you'll need to set up nested table storage for each of the collections in your XML Schema in order to the required performance when using the views.
    The easiest way will be to use the default table that is creted when registering the XML Schema and the annotation xdb:storeVarrayAsTable="true" and then ensure that you sequence each collection correctly.

  • How to format an account to show date format with MDX function @FORMATDATE

    Hello,
    I am working with an ASO cube where all accounts are set as numeric type. We have some accounts which hold date information for eg Date1 member which is a stored member will have data as 20120601 for June 1st 2012. In financial reports, i need to show this data as 06/01/2012 and using as essbase connection in FR, i cannot do this.
    While i was looking for a solution, i came across the MDX function called
    @FORMATDATE
    format_string_expression = MdxFormat ( string_value_expression )
    I was hoping that if i add a member say Date2 and make it dynamic and point it to Date1 and have this MDX format command to make the numeric data 20120601 show up as 06/01/2012.
    Can this work and if yes, what would be the MDX formula in this case?
    Any help in this regard will be a great help...the other alternative i have is to export this date data out into an oracle table, transform that data into to_date and after enabling the type measures in the outline, load it back in...i was hoping to avoid this extra route if this can be done with the formatting via MDX withing the essbase app.
    Thanks...

    For all good order, here is the log from the Disk Utility:
    2012-12-07 21:18:03 +0100: Disk Utility started.
    2012-12-07 21:21:46 +0100: Preparing to partition disk: “WDC WD30 EZRX-00DC0B0 Media”
    2012-12-07 21:21:46 +0100:     Partition Scheme: GUID Partition Table
    2012-12-07 21:21:46 +0100:     1 partition will be created
    2012-12-07 21:21:46 +0100:
    2012-12-07 21:21:46 +0100:     Partition 1
    2012-12-07 21:21:46 +0100:         Name        : “Gardermoen”
    2012-12-07 21:21:46 +0100:         Size        : 3 TB
    2012-12-07 21:21:46 +0100:         File system    : Mac OS Extended (Journaled)
    2012-12-07 21:21:46 +0100:
    2012-12-07 21:21:46 +0100: Unmounting disk
    2012-12-07 21:27:59 +0100: Partition failed for disk WDC WD30 EZRX-00DC0B0 Media Wiping volume data to prevent future accidental probing failed.
    B*gger.  :-(

  • Print out lists of formats with their settings

    I would like the ability to print out a complete list of paragraph, character, table, and cross-reference formats (with their settings) for inclusion in a local style guide.

    Julee,
    Those files were .zip files wrapped in 7zip wrappers - very strange. Any way, I've attached the MIF_munch here in a single .zip file.
    Note: the file is named Mif_munch.zip.txt to fool the upload file type restrictions. Just delete the .txt extension and unzip.
    It might take a few hours or so to clear the scanning queue.

  • RSA decryption Error: Data must start with zero

    Because of some reasons, I tried to use RSA as a block cipher to encrypt/decrypt a large file. When I debug my program, there some errors are shown as below:
    javax.crypto.BadPaddingException: Data must start with zero
         at sun.security.rsa.RSAPadding.unpadV15(Unknown Source)
         at sun.security.rsa.RSAPadding.unpad(Unknown Source)
         at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:356)
         at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:394)
         at javax.crypto.Cipher.doFinal(Cipher.java:2299)
         at RSA.RRSSA.main(RRSSA.java:114)
    From breakpoint, I think the problem is the decrypt operation, and Cipher.doFinal() can not be operated correctly.
    I searched this problem from google, many people met the same problem with me, but most of them didn't got an answer.
    The source code is :
    Key generation:
    package RSA;
    import java.io.FileOutputStream;
    import java.io.ObjectOutputStream;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.PrivateKey;
    import java.security.PublicKey;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    public class GenKey {
          * @param args
                     * @author tang
         public static void main(String[] args) {
              // TODO Auto-generated method stub
                 try {
                      KeyPairGenerator KPG = KeyPairGenerator.getInstance("RSA");
                      KPG.initialize(1024);
                      KeyPair KP=KPG.genKeyPair();
                      PublicKey pbKey=KP.getPublic();
                      PrivateKey prKey=KP.getPrivate();
                      //byte[] publickey = decryptBASE64(pbKey);
                      //save public key
                      FileOutputStream out=new FileOutputStream("RSAPublic.dat");
                      ObjectOutputStream fileOut=new ObjectOutputStream(out);
                      fileOut.writeObject(pbKey);
                      //save private key
                          FileOutputStream outPrivate=new FileOutputStream("RSAPrivate.dat");
                      ObjectOutputStream privateOut=new ObjectOutputStream(outPrivate);
                                 privateOut.writeObject(prKey)
         }Encrypte / Decrypt
    package RSA;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.ObjectInputStream;
    import java.security.Key;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.crypto.Cipher;
    //import sun.misc.BASE64Decoder;
    //import sun.misc.BASE64Encoder;
    public class RRSSA {
          * @param args
         public static void main(String[] argv) {
              // TODO Auto-generated method stub
                //File used to encrypt/decrypt
                 String dataFileName = argv[0];
                 //encrypt/decrypt: operation mode
                 String opMode = argv[1];
                 String keyFileName = null;
                 //Key file
                 if (opMode.equalsIgnoreCase("encrypt")) {
                 keyFileName = "RSAPublic.dat";
                 } else {
                 keyFileName = "RSAPrivate.dat";
                 try {
                 FileInputStream keyFIS = new FileInputStream(keyFileName);
                 ObjectInputStream OIS = new ObjectInputStream(keyFIS);
                 Key key = (Key) OIS.readObject();
                 Cipher cp = Cipher.getInstance("RSA/ECB/PKCS1Padding");//
                 if (opMode.equalsIgnoreCase("encrypt")) {
                 cp.init(Cipher.ENCRYPT_MODE, key);
                 } else if (opMode.equalsIgnoreCase("decrypt")) {
                 cp.init(Cipher.DECRYPT_MODE, key);
                 } else {
                 return;
                 FileInputStream dataFIS = new FileInputStream(dataFileName);
                 int size = dataFIS.available();
                 byte[] encryptByte = new byte[size];
                 dataFIS.read(encryptByte);
                 if (opMode.equalsIgnoreCase("encrypt")) {
                 FileOutputStream FOS = new FileOutputStream("cipher.txt");
                 //RSA Block size
                 //int blockSize = cp.getBlockSize();
                 int blockSize = 64 ;
                 int outputBlockSize = cp.getOutputSize(encryptByte.length);
                 /*if (blockSize == 0)
                      System.out.println("BLOCK SIZE ERROR!");       
                 }else
                 int leavedSize = encryptByte.length % blockSize;
                 int blocksNum = leavedSize == 0 ? encryptByte.length / blockSize
                 : encryptByte.length / blockSize + 1;
                 byte[] cipherData = new byte[outputBlockSize*blocksNum];
                 //encrypt each block
                 for (int i = 0; i < blocksNum; i++) {
                 if ((encryptByte.length - i * blockSize) > blockSize) {
                 cp.doFinal(encryptByte, i * blockSize, blockSize, cipherData, i * outputBlockSize);
                 } else {
                 cp.doFinal(encryptByte, i * blockSize, encryptByte.length - i * blockSize, cipherData, i * outputBlockSize);
                 //byte[] cipherData = cp.doFinal(encryptByte);
                 //BASE64Encoder encoder = new BASE64Encoder();
                 //String encryptedData = encoder.encode(cipherData);
                 //cipherData = encryptedData.getBytes();
                 FOS.write(cipherData);
                 FOS.close();
                 } else {
                FileOutputStream FOS = new FileOutputStream("plaintext.txt");
                 //int blockSize = cp.getBlockSize();
                 int blockSize = 64;
                 //int j = 0;
                 //BASE64Decoder decoder = new BASE64Decoder();
                 //String encryptedData = convert(encryptByte);
                 //encryptByte = decoder.decodeBuffer(encryptedData);
                 int outputBlockSize = cp.getOutputSize(encryptByte.length);
                 int leavedSize = encryptByte.length % blockSize;
                 int blocksNum = leavedSize == 0 ? encryptByte.length / blockSize
                           : encryptByte.length / blockSize + 1;
                 byte[] plaintextData = new byte[outputBlockSize*blocksNum];
                 for (int j = 0; j < blocksNum; j++) {
                 if ((encryptByte.length - j * blockSize) > blockSize) {
                      cp.doFinal(encryptByte, j * blockSize, blockSize, plaintextData, j * outputBlockSize);
                      } else {
                      cp.doFinal(encryptByte, j * blockSize, encryptByte.length - j * blockSize, plaintextData, j * outputBlockSize);
                 FOS.write(plaintextData);
                 //FOS.write(cp.doFinal(encryptByte));
                 FOS.close();
    }Edited by: sabre150 on Aug 3, 2012 6:43 AM
    Moderator action : added [ code] tags so as to make the code readable. Please do this yourself in the future.
    Edited by: 949003 on 2012-8-3 上午5:31

    1) Why are you not closing the streams when writing the keys to the file?
    2) Each block of RSA encrypted data has size equal to the key modulus (in bytes). This means that for a key size of 1024 bits you need to read 128 bytes and not 64 bytes at a time when decrypting ( this is probably the cause of your 'Data must start with zero exception'). Since the input block size depends on the key modulus you cannot hard code this. Note - PKCS1 padding has at least 11 bytes of padding so on encrypting one can process a maximum of the key modulus in bytes less 11. Currently you have hard coded the encryption block at 64 bytes which is OK for your 1024 bits keys but will fail for keys of modulus less than about 936 bits.
    3) int size = dataFIS.available(); is not a reliable way to get the size of an input stream. If you check the Javadoc for InputStream.available() you will see that it returns the number of bytes that can be read without blocking and not the stream size.
    4) InputStream.read(byte[]) does not guarantee to read all the bytes and returns the number of bytes actually read. This means that your code to read the content of the file into an array may fail. Again check the Javadoc. To be safe you should used DataInputStream.readFully() to read a block of bytes.
    5) Reading the whole of the cleartext or ciphertext file into memory does not scale and with very large files you will run out of memory. There is no need to do this since you can use a "read a block, write the transformed block" approach.
    RSA is a very very very slow algorithm and it is not normal to encrypt the whole of a file using it. The standard approach is to perform the encryption of the file content using a symmetric algorithm such as AES using a random session key and use RSA to encrypt the session key. One then writes to the ciphertext file the RSA encrypted session key followed by the symmetric encrypted data. To make it more secure one should actually follow the extended procedure outlined in section 13.6 of Practical Cryptography by Ferguson and Schneier.

Maybe you are looking for