This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [SHOWOFF] Directory-Extractor Java - Only Code  (Read 2550 times)

lordshark

  • Registred Member
  • GM Isle Explorer
  • *****
  • Posts: 24
    • View Profile
[SHOWOFF] Directory-Extractor Java - Only Code
« 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);
}
}

}
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [SHOWOFF] Directory-Extractor Java - Only Code
« Reply #1 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.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

lordshark

  • Registred Member
  • GM Isle Explorer
  • *****
  • Posts: 24
    • View Profile
Re: [SHOWOFF] Directory-Extractor Java - Only Code
« Reply #2 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 :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »