How to zip a LARGE file using zipOutputStream
Hi,
I am trying to zip a file which is over 50MB, and I got an "Out-of-Memory" error.
Here is part of the java program:
public static String Zipper(String Path,String ZipName,String FilestoZip, boolean DeleteFile){
/* This function archives a given subdirectory and the deletes the
archived files.
Parameters: Path => Full path of the zipped file subdirectory
Zipname => Name of the zip file to create
FilestoZip => List of files to zip.
Return: Message status if completed or not
try{
Msg = "COMPLETE:Creating zip file "+ZipName;
ZipOutputStream zip = new ZipOutputStream( new FileOutputStream(ZipName));
zip.setMethod(ZipOutputStream.DEFLATED);
zip.setLevel(Deflater.BEST_COMPRESSION);
File file= new File(FilestoZip);
FileInputStream in = new FileInputStream(file);
byte[] bytes = new byte[in.available()];
in.read(bytes);
in.close();
ZipEntry entry = new ZipEntry(file.getName());
entry.setTime(file.lastModified());
zip.putNextEntry(entry);
zip.write(bytes);
zip.closeEntry();
zip.close();
catch (Exception e) {Msg = e.getLocalizedMessage();}
This program works fine with small files, but when the file size gets bigger, it will create "out-of-memory" error.
Does anybody know how to work around this?
I appreciate your help.
Michelle
I modified the program as follow:
ZipEntry entry = new ZipEntry(file.getName());
entry.setTime(file.lastModified());
zip.putNextEntry(entry);
byte[] bytes=new byte[1024];
int len;
while ((len=in.read(bytes))>0) {
zip.write(bytes,0,len);
And now it is working. I can zip a file with 125MB size.
Thank you for your help.
Michelle
Similar Messages
-
How to Zip a Large File into Several Mini Zip Files?
Hi Everyone,
I've got a few camera video clips (about 100MB in size each) that I would like to send through e-mail.
I've got to split them into smaller pieces, but how do I get this done?
I don't want to use third party applications (if possible)
I've Googled and found a few suggestions but I can't seem to get anything done.
I tried the Terminal approach, but the command "zip" does not exist.
man zip does not exist...
If I do a Create Archive - it will result in a single zip file, but I need to split it to a few segments, plus I'm trying to send these to Windows users.
Please help, and thanks in advance...Hi Sagasse buddy, thanks for your reply.
Found something interesting as I was browsing VersionTracker.
Zip Tools 1.1 at http://versiontracker.com/dyn/moreinfo/macosx/15462
+Product Description:+
+Installs zip 2.32 and unzip 5.52 files.+
+I noticed some time ago that there are a lot of machines out there without a copy of the zip and unzip binaries that Apple installs as part of their Developer Tools. As these tools are very useful, and several people, including myself, have written applications or scripts that depend at least in part on this binaries, I've built an installer.+
+Note, I didn't make the binaries, I'm just redistributing them because they can be hard to find and install if you're not "in the know".+
+These binaries are meant to be used from the Terminal and include no GUI, let alone an Aqua one. For your convenience, I have included a drag-and-drop AppleScript that will allow you to use the tools without going to the Terminal.+
Maybe I do not have those binaries in my machine...
I'll try out your suggestion as well as this Zip Tools 1.1 thingy.
Message was edited by: Jeffry® -
How do I move large files from a Windows computer to my MacBook Pro? There are a lot of photos (tiffs, jpgs, some photoshopped files), iTunes library, word docs. Is there a particular type of external hard drive that can be used or am I limited to copying stuff onto z-drive and moving that way?
If both computers are on the same network, you can share the files from the Windows host using SMB and mount the share on the Mac. Otherwise, the Mac should be able to read (not necessarily write) any storage device formatted in Windows.
-
How can I delete large files on my MacBook Pro?
How can I delete large files on my MacBook Pro? Also my Emails wont delete, how can I delete them?
Which email client are you using & which version? Your emails are not appearing in the email trashcan?
-
How to send a large file in XI ?
How to send a large file in XI ?
hi,
use a splitting mechanism to convert large files into smaller files and process them as if they where independent.
You can use the "Recordsets Per Message" parameter in the File Adapter sender comm channel by using File Content Conversion, to create a new message for each 1000,10000,etc records in the source file...this could be a way of splitting.
If you scenario works ok for small files, maybe you can develop another scenario that runs previous the current one, that only splits files (e.g. File-XI-File) and then puts the output smaller files in the directory that your current scenario monitors.
Check this blog for huge file processing
/people/alessandro.guarneri/blog/2007/02/21/sap-xi-acting-as-a-huge-file-mover
Thanks,
Vijaya -
How do I delete large files, so they don't take 12 to 16 hours to delete?
Don't use the Secure Empty Trash option on items which don't contain sensitive data. If the Trash is always doing it, create two folders with the same name in different locations, drag the files into one, and move the other into the folder which contains the first.
(51817) -
How do i delete large files and pics of my mac book pro
how do i delete large files and pics of my mac book pro
Make sure that you do not delete any system file, or part of an application.
Use Omnidisksweeper as a search tool http://www.omnigroup.com/more -
Does anyone know how i can view PDF files using Galaxy Note 2?
Does anyone know how i can view PDF files using Galaxy Note 2?
This is what i have been doing;
I click on the file i wish to view (via a portal)
this file goes to notification widget (i drag down screen)
notification/message says download complete
i click on notification/message
nows it says complete action using (here i only have 2 icon options 1= DB Text Editor 2 = HTML Viewer)
I have installed Adobe Reader.Can you confirm if the downloaded file is a pdf file, that is it ends with .pdf?
-
How to zip a text file and send as email attachment in SAP version 4.6c?
Hi Guru,
How to zip a text file in SAP version 4.6c which doesn't have class CL_ABAP_ZIP?
Please help.
Thanks & Regards,
AriHi,
Try this link
[http://sap.ittoolbox.com/groups/technical-functional/sap-dev/sapr3dev-zip-file-from-sap-1707099?cv=expanded]
Cheers,
Surinder -
How to create new XML file using retreived XML content by using SAX API?
hi all,
* How to create new XML file using retreived XML content by using SAX ?
* I have tried my level best, but output is coming invalid format, my code is follows,
XMLFileParser.java class :-
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.XMLFilterImpl;
public class PdfParser extends XMLFilterImpl {
private TransformerHandler handler;
Document meta_data;
private StringWriter meta_data_text = new StringWriter();
public void startDocument() throws SAXException {
void startValidation() throws SAXException {
StreamResult streamResult = new StreamResult(meta_data_text);
SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
try
handler = factory.newTransformerHandler();
Transformer transformer = handler.getTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
handler.setResult(streamResult);
handler.startDocument();
catch (TransformerConfigurationException tce)
System.out.println("Error during the parse :"+ tce.getMessageAndLocation());
super.startDocument();
public void startElement(String namespaceURI, String localName,
String qualifiedName, Attributes atts) throws SAXException {
handler.startElement(namespaceURI, localName, qualifiedName, atts);
super.startElement(namespaceURI, localName, qualifiedName, atts);
public void characters(char[] text, int start, int length)
throws SAXException {
handler.characters(text, start, length);
super.characters(text, start, length);
public void endElement(String namespaceURI, String localName,
String qualifiedName) throws SAXException {
super.endElement("", localName, qualifiedName);
handler.endElement("", localName, qualifiedName);
public void endDocument() throws SAXException {
void endValidation() throws SAXException {
handler.endDocument();
try {
TransformerFactory transfactory = TransformerFactory.newInstance();
Transformer trans = transfactory.newTransformer();
SAXSource sax_source = new SAXSource(new InputSource(new StringReader(meta_data_text.toString())));
DOMResult dom_result = new DOMResult();
trans.transform(sax_source, dom_result);
meta_data = (Document) dom_result.getNode();
System.out.println(meta_data_text);
catch (TransformerConfigurationException tce) {
System.out.println("Error occurs during the parse :"+ tce.getMessageAndLocation());
catch (TransformerException te) {
System.out.println("Error in result transformation :"+ te.getMessageAndLocation());
} CreateXMLFile.java class :-
Sax.startDocument();
Sax.startValidation();
Sax.startElement("", "pdf", "pdf", new AttributesImpl());
Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());
String xmp_str = new String(meta_data.getByteArray(),"UTF8");
char[] xmp_arr = xmp_str.toCharArray();
Sax.characters(xmp_arr, 0, xmp_arr.length);
Sax.endElement("", "pdf", "pdf");
Sax.endValidation();
Sax.endDocument();
Sax.endElement("", "basic-metadata", "basic-metadata");* In CreateXMLFile.java
class, I have retreived the xml content in the meta_data object, after that i have converted into character array and this will be sends to SAX
* In this case , the XML file created successfully but the retreived XML content added as an text in between basic-metadata Element, that is, retreived XML content
is not an XML type text, it just an Normal text Why that ?
* Please help me what is the problem in my code?
Cheers,
JavaImranSax.startDocument();
Sax.startValidation();
Sax.startElement("", "pdf", "pdf", new AttributesImpl());
Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());
String xmp_str = new String(meta_data.getByteArray(),"UTF8");
char[] xmp_arr = xmp_str.toCharArray();
Sax.characters(xmp_arr, 0, xmp_arr.length);
</code><code>Sax.endElement("", "basic-metadata", "basic-metadata");</code>
<code class="jive-code jive-java">Sax.endElement("", "pdf", "pdf");
Sax.endValidation();
Sax.endDocument();
* I HAVE CHANGED MY AS PER YOUR SUGGESTION, NOW SAME RESULT HAS COMING.
* I AM NOT ABLE TO GET THE EXACT OUTPUT.,WHY THAT ?
Thanks,
JavaImran{code} -
How to upload an excel file using ABAP.
Hi,
Can anyone please help me in understanding how to upload an excel file using ABAP.
Thanks!!http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/
check the link
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
PARAMETER p_infile like rlgrap-filename.
*START OF SELECTION
call function ALSM_EXCEL_TO_INTERNAL_TABLE
exporting
filename = p_infile
i_begin_col = 1′
i_begin_row = 2′ Do not require headings
i_end_col = 14′
i_end_row = 31′
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. Problem uploading Excel Spreadsheet
endif.
Sort table by rows and colums
sort itab by row col.
Get first row retrieved
read table itab index 1.
Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when 0001′. First name
wa_record-name1 = itab-value.
when 0002′. Surname
wa_record-name2 = itab-value.
when 0003′. Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop. -
How to read a text file using Java
Guys,
Good day!
Please help me how to read a text file using Java and create/convert that text file into XML.
Thanks and God Bless.
Regards,
I-Talkpublic void fileRead(){
File aFile =new File("myFile.txt");
BufferedReader input = null;
try {
input = new BufferedReader( new FileReader(aFile) );
String line = null;
while (( line = input.readLine()) != null){
catch (FileNotFoundException ex) {
ex.printStackTrace();
catch (IOException ex){
ex.printStackTrace();
}This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
cheers
Mohammed Jubaer Arif. -
How to specify a mapping file using annotations?
Hi,
i am trying to deploy a WebService (with annotations) on oc4j 10.1.3.1.0. but all i get is the following exception:
07/03/13 12:41:52 oracle.j2ee.ws.common.tools.api.ValidationException: test.datamodel.SimpleObjectId - Duplicate type name "test.datamodel.SimpleObjectId" for Java type "{http://tdeer.de/services/internal/test/1_0}SimpleObjectId" found. To remove this error do not specify a single typeNamespace for all value types or specify a mapping file. This error could also be caused when an erroneous type has been used more than once.
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.RmiModeler.buildModel(RmiModeler.java:247)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.config.ModelInfo.buildModel(ModelInfo.java:173)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.Processor.runModeler(Processor.java:72)
07/03/13 12:41:52 at oracle.j2ee.ws.common.metadata.annotation.DeploymentGenerator$DeploymentCompileTool.run(DeploymentGenerator.java:200)
07/03/13 12:41:52 at oracle.j2ee.ws.common.metadata.annotation.DeploymentGenerator.generateDeploymentArtifacts(DeploymentGenerator.java:131)
07/03/13 12:41:52 at oracle.j2ee.ws.common.metadata.annotation.EJBWebServiceAnnotationParser.parseAnnotatedBean(EJBWebServiceAnnotationParser.java:165)
07/03/13 12:41:52 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
07/03/13 12:41:52 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
07/03/13 12:41:52 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
07/03/13 12:41:52 at java.lang.reflect.Method.invoke(Method.java:585)
07/03/13 12:41:52 at oracle.j2ee.ws.server.deployment.oc4j.WebServiceAnnotationListener.parseAnnotatedClass(WebServiceAnnotationListener.java:85)
07/03/13 12:41:52 at com.evermind.server.ejb.AnnotationParser.notifyAnnotationListeners(AnnotationParser.java:201)
07/03/13 12:41:52 at com.evermind.server.ejb.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
07/03/13 12:41:52 at com.evermind.server.ejb.EJBPackageDeployment.parseMetaData(EJBPackageDeployment.java:939)
07/03/13 12:41:52 at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:832)
07/03/13 12:41:52 at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:217)
07/03/13 12:41:52 at com.evermind.server.Application.setConfig(Application.java:413)
07/03/13 12:41:52 at com.evermind.server.Application.setConfig(Application.java:314)
07/03/13 12:41:52 at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1853)
07/03/13 12:41:52 at oracle.oc4j.admin.internal.ApplicationDeployer.addApplication(ApplicationDeployer.java:512)
07/03/13 12:41:52 at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:196)
07/03/13 12:41:52 at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93)
07/03/13 12:41:52 at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
07/03/13 12:41:52 at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
07/03/13 12:41:52 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)
07/03/13 12:41:52 at java.lang.Thread.run(Thread.java:595)
07/03/13 12:41:52 Caused by: oracle.j2ee.ws.common.processor.modeler.rmi.InvalidParameterException: test.datamodel.SimpleObjectId - Duplicate type name "test.datamodel.SimpleObjectId" for Java type "{http://tdeer.de/services/internal/test/1_0}SimpleObjectId" found. To remove this error do not specify a single typeNamespace for all value types or specify a mapping file. This error could also be caused when an erroneous type has been used more than once.
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.LiteralTypeModeler.addTypeName(LiteralTypeModeler.java:1249)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.LiteralTypeModeler.processClass(LiteralTypeModeler.java:290)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.LiteralTypeModeler.modelTypeLiteral(LiteralTypeModeler.java:235)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.LiteralTypeModeler.modelTypeLiteral(LiteralTypeModeler.java:181)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.LiteralTypeModeler.modelSubclasses(LiteralTypeModeler.java:1048)
07/03/13 12:41:52 at oracle.j2ee.ws.common.processor.modeler.rmi.RmiModeler.buildModel(RmiModeler.java:210)
07/03/13 12:41:52 ... 25 more
The Stateless-SessionBean has one WebMethod with the following Signature:
public Element getElement(TestObjectId1 pObjectId1, TestObjectId2 pObjectId2) throws RemoteException
TestObjectId1 and TestObjectId2 have the same Superclass, SimpleObjectId.
How to specify a mapping file using annotations?
Thanks
tdeerWe you codegen a Policy annotated WSDL, the policies are get included in the stub. Hence you don't have to specify a separate Policy file.
But if you need to use a separate policy then you need to set them in the AxisDescription object that you use in the ServiceClient and OperationClient.
e.g.
ServiceClient serviceClient = new ServiceClient();
OperationClient operationClient = serviceClient
.createClient(ServiceClient.ANON_OUT_IN_OP);
FileInputStream fis = new FileInputStream("path-to-policy.xml");
Policy servicePolicy = PolicyEngine.getPolicy(fis);
AxisService axisService = serviceClient.getAxisService();
axisService.getPolicyInclude().setPolicy(servicePolicy);
If you need more information please repost this to [email protected] with a [AXIS2] subject prefix. -
Processing Large Files using Chunk Mode with ICO
Hi All,
I am trying to process Large files using ICO. I am on PI 7.3 and I am using new feature of PI 7.3, to split the input file into chunks.
And I know that we can not use mapping while using Chunk Mode.
While trying I noticed below points:
1) I had Created Data Type, Message Type and Interfces in ESR and used the same in my scenario (No mapping was defined)Sender and receiver DT were same.
Result: Scenario did not work. It created only one Chunk file (.tmp file) and terminated.
2) I used Dummy Interface in my scenario and it worked Fine.
So, Please confirm if we should always USE DUMMY Interfaces in Scenario while using Chunk mode in PI 7.3 Or Is there something that I am missing.
Thanks in Advance,
- Pooja.Hello,
While trying I noticed below points:
1) I had Created Data Type, Message Type and Interfces in ESR and used the same in my scenario (No mapping was defined)Sender and receiver DT were same.
Result: Scenario did not work. It created only one Chunk file (.tmp file) and terminated.
2) I used Dummy Interface in my scenario and it worked Fine.
So, Please confirm if we should always USE DUMMY Interfaces in Scenario while using Chunk mode in PI 7.3 Or Is there something that I am missing.
According to this blog:
File/FTP Adapter - Large File Transfer (Chunk Mode)
The following limitations apply to the chunk mode in File Adapter
As per the above screenshots, the split never cosiders the payload. It's just a binary split. So the following limitations would apply
Only for File Sender to File Receiver
No Mapping
No Content Based Routing
No Content Conversion
No Custom Modules
Probably you are doing content conversion that is why it is not working.
Hope this helps,
Mark
Edited by: Mark Dihiansan on Mar 5, 2012 12:58 PM -
How to open a pdf file using OPEN DATASET
Im trying to convert a pdf into binary format. So im trying to read the contents of the pdf into a XSTRING. Using the FM 'SCMS_XSTRING_TO_BINARY' i can convert the XSTRING to binary format.
How to open a pdf file using OPEN DATASET and transfer its contents in a XSTRING variable.
What i've tried is....
DATA: f_name type string value 'C:\rep_output_pdf.pdf',
x1 type xstring,
LT_DATA TYPE STANDARD TABLE OF X255.
OPEN DATASET f_name FOR input IN BINARY MODE.
READ DATASET f_name INTO x1.
CLOSE DATASET f_name.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = x1
TABLES
BINARY_TAB = LT_DATA.
Im getting a short dump .
Short text: The file is not open.
Plz help me out.Hello Rajesh,
You are trying to do use OPEN DATASET with a local file. NOT POSSIBLE
You have to have the file in the app server to use OPEN DATASET.
BR,
Suhas
Maybe you are looking for
-
Create PO with the check box of free item selected automaticly
Hi all, We would like to create PO's with a normal position and a second position which is free. Is there a possibility to have a special position type for free goods? We don't want to check this checkbox every time we create a PO... Thanks, Thomas
-
Hi all, Please tell me what are the mandatory fields in the creation of profile ? what are the diff. config. settings? thnx
-
Use HTTPS to access webservice on standalone OC4J
I have followed the instructions in the Oracle Containers for J2EE Security Guide for setting up SSL (Chapter 15) on standalone OC4J. I have also looked at Tugs blog about using HTTPS with web services. I believe I have everything setup right but hav
-
I'm running Aperture 3.1.3 (in 32-bit mode) on OS X Lion. I used to be able to share my Aperture photos with iWork, in Mail, and in the Screensaver, but now I cannot. I have "Preview Sharing" turned on in the Aperture Preferences. I've tried trash
-
I returned a macbook air 13" from john lewis in the store , then i refunded it, and i purchased it again but this time online. Would it be the same one? Thanks Nathan