Created
May 28, 2012 17:01
-
-
Save tobgu/2820093 to your computer and use it in GitHub Desktop.
Profiling with visual VM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package primegenerator; | |
import java.io.BufferedOutputStream; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.OutputStreamWriter; | |
import java.io.Writer; | |
//import org.springframework.stereotype.Component; | |
// @Component | |
public class FileDestination implements IPrimeDestination { | |
private final String fileName; | |
private Writer out; | |
public FileDestination(String fileName) { | |
this.fileName = fileName; | |
} | |
public void initBean() { | |
out = null; | |
try { | |
out = new OutputStreamWriter( | |
new BufferedOutputStream(new FileOutputStream(fileName, true), 8192)); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} | |
System.out.println("Init called"); | |
} | |
public void destroyBean() { | |
try { | |
if(out != null) { | |
out.close(); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
System.out.println("Destroy called"); | |
} | |
@Override | |
public void put(long prime) { | |
try { | |
out.write(Long.toString(prime) + "\n"); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment