Archive for August, 2012

Exception ZipFile

Thursday, August 23rd, 2012

He works professionally with Java he has 7 years and he possesss 4 years of experience in the development of systems for the IBM of the United States, used the world-wide level. He acts more than has 2 years with courses and training of professionals in great companies. It possesss the certifications of Sun SCJP, SCJD, SCWCD, SCBCD, SCEA, IBM SOUNDS and ITIL Foundation. Code-source used in the article: package zip; import java.io.Fi le; import java.io.Fi leInputStream; import java.io.Fi leOutputStream; import java.io.IO Exception; import java.io.In putStream; import java.io.Ou tputStream; import java.util. Enumeration; import java.util. Stack; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; public class ZipHelper public void zip (File files, File outputFile) throws IOException if (files! = null & & files.length > 0) ZipOutputStream out = new ZipOutputStream (new FileOutputStream (outputFile)); Stack parentDirs = new Stack (); zipFiles (parentDirs, files, out); out.close (); private void zipFiles (Stack parentDirs, File files, ZipOutputStream out) throws IOException byte buf = new byte 1024; i will be (int = 0; i 0) out.write (buf, 0, len); out.closeEntry (); in.close (); public void unzip (File zipFile, File to dir) throws IOException ZipFile zip = null; File archive = null; InputStream is = null; OutputStream = null; byte buffer = new byte 1024; try // creates informed directory, in case that if does not exist (! dir.exists ()) dir.mkdirs (); if (! dir.exists () dir.isDirectory ()) throw new IOException (' ' The directory ' ' + dir.getName () + ' ' vlido&#039 is not a directory; '); zip = new ZipFile (zipFile); Enumeration = zip.entries (); while (e.hasMoreElements ()) Entered ZipEntry = (ZipEntry) e.nextElement (); archive = new File (to dir, entrada.getName ()); // will be inexistent directory, creates the structure and polishes pra next entered if (entrada.isDirectory () & & arquivo.exists ()) arquivo.mkdirs (); it continues; // if the structure of directories does not exist, creates if (! arquivo.getParentFile () .exists ()) arquivo.getParentFile () .mkdirs (); try // reads the archive of zip and records in record is = zip.getInputStream (entered); = new FileOutputStream (archive); int bytesLidos = 0; if (is == null) throw new ZipException (' ' Error when reading the entrance of zip: ' ' + entrada.getName ()); while ((bytesLidos = is.read (buffer)) > 0) os.write (buffer, 0, bytesLidos); finally if (is! = null) try is.close (); catch (former Exception) if (! = null) try os.close (); catch (former Exception) finally if (zip! = null) try zip.close (); catch (Exception e)

Tips Calculating Google

Friday, August 10th, 2012

Wednesday, 18 of January of 2012 12:02 #006 Radiciao Radiciao is the operation for which if it calculates the root of a number or expression. The Google can return the root from any number. It sees as: For square shaped root you can use sqr, sqrt or square root or still square root of n, where n is the number of which we want to get the root. They are four different forms to get the square shaped root of a number, I I prefer simplest than he is sqr. It sees examples: sqr 4 sqrt 4 square root (4) square root of 4 google facilitates its life very and you it can ask on the root also squares of a number in Portuguese: square shaped root (4) square shaped root of 4 For cubical root you also can ask in English or Portuguese: cubical root of 8 cubical root (8) or cube root of 8 cube root (8) For fourth, fifth, sixth or any another root, is enough to use: 4a root of n 5a root of n 6a root of n 7a root of n 99a root of n Where n is the number of which we want to know the root. In English it is thus: 4th root of n 5th root of n 6th root of n 7th root of n CURIOSITY: When to use names in Portuguese the result will have comma decimal and when to use names in English the result will have point decimal. Wallas Nunes