Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Member
Posts: 2
Registered: ‎05-15-2012
My Device: developer
My Carrier: n/a

import java.util.zip.ZipOutputStream; causing issues with printing to a file

Well I assume it's that, or possibly the try I must use.

Writer output = null;
		File pdfFile = new File("MANIFEST.txt");//create text file
		try {
			output = new BufferedWriter(new FileWriter(pdfFile));
		} catch (IOException e) {
			 //TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for(int i=0; i<files.length; i++){//create manifesto of pdfs in directory
			try {
				
				System.out.println(copy[i]);
				output.write(copy[i]);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}			

 copy is an array of strings. The contents properly print to the console, but not to the file (the file is created though). When I include the import java.util.zip.ZipOutputStream;, alot of things become syntax errors (such as output.write) unless I put them in a try catch.

 

So, question number 1 is how do I fix it to output to a file

 

and 2 for curiosities sake, when I add the new include, why do so many things that were valid and working as intended no longer do so?

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: import java.util.zip.ZipOutputStream; causing issues with printing to a file

welcome to the support forums.

java.util.zip.ZipOutputStream is not a class in the BB API.
there is http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/compress/GZIPOutputStream.html

as some other classes are also desktop java it seems you have mixed up some things.
blackberry java is based on j2me + extensions, you cannot use desktop java (j2se).
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Member
Posts: 2
Registered: ‎05-15-2012
My Device: developer
My Carrier: n/a

Re: import java.util.zip.ZipOutputStream; causing issues with printing to a file

I'll be honest with you, this isn't for a blackberry, or any phone. This is for a computer. I came here out of desperation, because this has me (and 3 friends) completely stumped, and this is the only java forum I have found that had any recent posts.

Highlighted
Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: import java.util.zip.ZipOutputStream; causing issues with printing to a file

try stackoverflow.com
or oracle forums (the java manufacturer). or...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter