Modcraft - The community dedicated to quality WoW modding!

Community => Showoff - what you are working on => Topic started by: lordshark on January 11, 2012, 03:06:05 pm

Title: [SHOWOFF] Directory-Extractor Java - Only Code
Post by: lordshark on January 11, 2012, 03:06:05 pm
Greetings,
i create a simple java program to extract the directory from the modelviewer log text file and save them to a text files. Without GUI! Only console program! You need some Java knowhow(compiling code etc)

1. Dir = Your Modelviewer directory (example: C:ModelvieweruserSettingslog.txt
2. Dir = Your directory to save the file (example: C:Dir.txt)

Auf Deutsch,
ich hab ein Programm in Java geschrieben um die Pfade der Modelle heraus zu nehmen und in zwei verschiedene Textdateien zu speichern. Ich hab keine Lust immer alles heraus zu suchen aus der log.txt und kann sehr nützlich für zB Taliis oder sonstige Programme sein, indem man Pfade benötigt.
Dachte mir ich tue jedenfalls etwas für die Community und wenn mir jemand meinen Text in ein gramatischkorrekten Satz umschreiben könnte wäre ich dem sehr verbunden.
Der Plan war ja die Pfade zB automatisch in DBC Files schreiben zu lassen, aber kenne keinen OpenSource Leser von DBCs in Java.

And sorry for my bad english.

Code: [Select]
import java.io.*;

public class ExtractorMdv
{
public static void main(String[] args)
{
String Dir1;
String Dir2;
Dir1 = "YOUR DIRECTORY TO MODELVIEWER EX: C:/Modelviewer/userSettings/log.txt";
Dir2 = "YOUR DIRECTORY TO SAVE YOUR FILE! EX: C:/DIR.TXT";
try
{

BufferedReader modelviewer =
new BufferedReader(
new FileReader(Dir1));
FileWriter dir =
new FileWriter(Dir2);
String str;
int counter;
counter = 0;
while ((str = modelviewer.readLine())!=null)
{
if (str.endsWith(".m2")||(str.endsWith(".wmo")))
           {
counter = counter +1;
System.out.println(str.substring(25, str.length()));
dir.write(str.substring(25, str.length())+"rn");
           } else{}
}
System.out.println("Existing Objects: "+counter);
modelviewer.close();
dir.close();
}
catch(FileNotFoundException e)
{
System.out.print(e);
}
catch(IOException e)
{
System.out.print(e);
}
}

}
Title: Re: [SHOWOFF] Directory-Extractor Java - Only Code
Post by: schlumpf on January 11, 2012, 03:34:57 pm
Will only — just as the great implementation in Noggit — work for a specific version of the model viewer with exactly 25 characters before the file name.  You should automatically detect the beginning.
Title: Re: [SHOWOFF] Directory-Extractor Java - Only Code
Post by: lordshark on January 11, 2012, 03:53:47 pm
I had seen it now, i made soon another version of it - but yeah, noggit great function is awesome ;-) Better then mine, but i need the directory for my own projects. Anyone can use my code, make it better or something like that. Only a idea to post something usefull :)