"Specified VM install not found: type Standard VM, name xxxrozwiazaniem jest usuniecie plikow w tym katalogu:
{eclipse_workspace_home}\.metadata\.plugins\org.eclipse.debug.core\.launches\pliki antowe wygladaja tak:
nazwa_projektu.build.xml.launch
Java, Tips'n'Tricks, rzeczy warte zapamietania, Programowanie. moj osobisty blog, prawdopodobnie bede takze jego jedynym odbiorca ;]
"Specified VM install not found: type Standard VM, name xxxrozwiazaniem jest usuniecie plikow w tym katalogu:
{eclipse_workspace_home}\.metadata\.plugins\org.eclipse.debug.core\.launches\pliki antowe wygladaja tak:
nazwa_projektu.build.xml.launch
private double log2(double num, int podstawa){
return (Math.log(num)/Math.log(podstawa));
}
jesli ktos nie wie (i tak przeciez nikt tego nie czyta) czemu tak jest - polecam:
stronę wikipedii o logarytmach oczywiscie
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-jdk7-installer
sudo apt-get remove oracle-jdk7-installer
package java_home;
import java.util.Enumeration;
import java.util.Properties;
public class Printer {
/**
* @param args
*/
public static void main(String[] args) {
Properties p = System.getProperties();
Enumeration<Object> keys = p.keys();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
String value = (String)p.get(key);
if(key.contains("java.home"))
System.out.println(key ": " value);
}
}
}
if(key.contains("java.home"))
package stringi;
public enum StringEnum {
HEADER ("General Log HEADER"),
ROW_1 ("jakis tekst, row1:"),
ROW_2 ("siakis int:");
private String description;
private StringEnum(String s) {
description = s;
}
public String getDescription() {
return description;
}
}
a teraz, po tym przydługim wstępie - rozwiązanie problemu - RandomAccessFile.package stringi;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
public class NewTestRandomAccessFile {
private File file = null;
private RandomAccessFile generalFileWriter = null;
private Integer siakisInt = 0;
public NewTestRandomAccessFile(String fileName) {
try {
initGeneralLog(fileName);
} catch (IOException e) {
e.printStackTrace();
}
}
private void initGeneralLog(String fileName) throws IOException{
file = new File(fileName);
if(file.exists()){
file.delete();
file.createNewFile();
}
generalFileWriter = new RandomAccessFile(file, "rw");
generalFileWriter.writeBytes(buildGeneralLog());
}
private String buildGeneralLog(){
StringBuilder sb = new StringBuilder();
sb.append(StringEnum.HEADER.getDescription()) .append("\n");
sb.append(StringEnum.ROW_1.getDescription()) .append("some static data bla bla") .append("\n");
sb.append(StringEnum.ROW_2.getDescription()) .append(siakisInt +=150) .append("\n");
return sb.toString();
}
private void writeDataToGeneralLog(String output) throws IOException {
generalFileWriter.setLength(output.getBytes().length);
generalFileWriter.seek(0);
generalFileWriter.writeBytes(output);
}
private void closeLog() throws IOException{
if(generalFileWriter != null){
writeDataToGeneralLog(buildGeneralLog());
generalFileWriter.close();
}
}
public static void main(String[] args) throws IOException {
NewTestRandomAccessFile test = new NewTestRandomAccessFile("WrRaThY.txt");
for(int i = 0; i<10; i){
test.writeDataToGeneralLog(test.buildGeneralLog());
}
test.closeLog();
}
}
package stringi;
import java.io.FileWriter;
import java.io.IOException;
public class Filewriter {
/**
* @param args
*/
private static FileWriter fw = null;
private static int samplersProcessedCounter = 0;
public static void main(String[] args) throws IOException, InterruptedException {
int count = 10;
Filewriter my = new Filewriter();
for(int i = 0; i<count; i){
my.funkcja();
}
}
public void funkcja(){
try {
String line = "";
if (fw == null) {// initiate file writer
fw = new FileWriter("test.csv");
line = "col1, col2, col3\n";
fw.append(line);
}
line = "col1row" samplersProcessedCounter ", col2row" samplersProcessedCounter ", col3row" samplersProcessedCounter "\n";
fw.append(line);
samplersProcessedCounter ;
//WARNING! this is strange, probably will be unstable
fw.flush();
fw.close();
fw=null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
package stringi;
import java.io.FileWriter;
import java.io.IOException;
public class Filewriter {
/**
* @param args
*/
private static FileWriter fw = null;
private static int samplersProcessedCounter = 0;
public static void main(String[] args) throws IOException, InterruptedException {
int count = 10;
Filewriter my = new Filewriter();
for(int i = 0; i<count; i){
my.funkcja();
}
//NORMAL FLUSH AND CLOSE, AFTER EVERYTHING IS DONE
fw.flush();
fw.close();
}
public void funkcja(){
try {
String line = "";
if (fw == null) {// initiate file writer
fw = new FileWriter("test.csv");
line = "col1, col2, col3\n";
fw.append(line);
}
line = "col1row" samplersProcessedCounter ", col2row" samplersProcessedCounter ", col3row" samplersProcessedCounter "\n";
fw.append(line);
samplersProcessedCounter ;
/*WARNING! COMMENT!
fw.flush();
fw.close();
fw=null;*/
} catch (IOException e) {
e.printStackTrace();
}
}
}
public synchronized static String convertStringToHex(String str) {
char[] chars = str.toCharArray();
StringBuffer hex = new StringBuffer();
for (int i = 0; i < chars.length; i ) {
hex.append(Integer.toHexString((int) chars[i]));
}
return hex.toString();
}
public synchronized static String convertHexToString(String hex) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hex.length() - 1; i = 2) {
// grab the hex in pairs
String output = hex.substring(i, (i 2));
// convert hex to decimal
int decimal = Integer.parseInt(output, 16);
// convert the decimal to character
sb.append((char) decimal);
}
return sb.toString();
}