okeefe | the real moins moins a écrit :
ben là la classe (ou le jar dans laquelle elle est)que tu essaies d'executer n'est pas dans ton classpath....
au fait elle est pas dans un package ta classe?
|
j'exécute à partir du e:, ImportTxt.java et .class et à la racine de ce lecteur... j'ai donc mis e:\ dans le classpath
voici le code de la classe
Code :
- import java.io.*;
- import waba.io.*;
- import java.util.*;
- /** This program reads a txt file and creates a pdb with one record per line.
- * Note that it cannot be used in the device, only in desktop.
- */
- public class ImportTxt
- {
- // reads a text file
- public static void readFile(Vector v, InputStream is) throws Exception
- {
- v.removeAllElements();
- try
- {
- int b = is.read();
- char c;
- String s = "";
- while (b >= 0)
- {
- c = (char)b;
- if (c == '\n')
- {
- v.addElement(s);
- s = "";
- } else s += c;
- b = is.read();
- if ((char)b == '\r') b = is.read();
- }
- if (s.length() > 0)
- v.addElement(s);
- }
- finally
- {
- is.close();
- }
- }
- /** Note that strings are written in the Pascal format.
- Use DataStream.readString to read each line */
- public static void main(String []args)
- {
- waba.applet.JavaBridge.setNonGUIApp();
- if (args.length != 2)
- System.out.println("use java ImportTxt <input file> <output pdb filename.crtr.type>" );
- else
- if (args[1].indexOf('.') == -1 || args[1].indexOf('.') == args[1].lastIndexOf('.'))
- System.out.println("Please specify the output pdb filename with the creator and type" );
- else
- try
- {
- // part 1 - reads the text file
- InputStream is = new FileInputStream(args[0]);
- Vector v = new Vector(1024);
- readFile(v,is);
- // part 2 - open the catalog
- Catalog catC = new Catalog(args[1],Catalog.READ_WRITE);
- if (!catC.isOpen())
- {
- catC = new Catalog(args[1],Catalog.CREATE);
- System.out.println("new file "+args[1]+" being created" );
- }
- else
- System.out.println("File "+args[1]+" already exists. Appending to it..." );
- ResizeStream rsC = new ResizeStream(catC,8192);
- DataStream dsC = new DataStream(rsC);
- // part 3 - writes the lines readen into separated records to the pdb file
- // note: you could also write it as one big string array, converting the Vector
- // to it and using the method dsC.writeStringArray. but it will be more memory consuming approach
- int n = v.size();
- for (int i =0; i < n; i++)
- if (rsC.startRecord())
- {
- dsC.writeString((String)v.elementAt(i));
- rsC.endRecord();
- }
- dsC.close();
- System.out.println("Finished with success." );
- } catch (Exception e) {e.printStackTrace();}
- }
- }
|
j'obtient toujours la même erreur |