FileInputStream() I/O in J2ME

Hi all...
I want to ask something. Is there any way to make a new file or read something from a file on handhelds application, because I read the J2ME API and it said that some I/O functions in J2EE like FileInputStream and FileOutputStream are excluded, and there are only some like BufferedReader or DataInputStream all its cousins. So, can anyone help me or give me any suggestions on how to make or read file for an app that is built with J2ME?
Thanks in advance.

Most phones don't even have a file system, so how would you create a file?
For local storage, use the RMS.
The phone might support the GCF Connection URL of "file://", but this is very unlikely, some phones might sport extra API for access the FS, you will need to check with your phone manufacture.

Similar Messages

  • Howto Export key from J2ME keystore

    I have generated a keypair with the J2ME WTK Sign MIDLet GUI tool, so the key is in the default WTK keystore (_main.ks). I need to get the key into a J2SE keystore so that I can use the keytool utility to manage the key and a certificate. How can I export the J2ME key so that I can import it into a new keystore? There is no option on the WTK tools and I have not been able to open the J2ME keystore with keytool (i.e., the format is different and I don't know what the default password is). Any help would be much appreciated.

    It is sure that you can't export a private key with keytool, only in a java program...
    here is a code i found in this forum , not mine, thks for it's owner...
    maybe it can inspire u...
    @echo off
    echo Starting...
    set KS=mykeystore
    set ALIAS=alias
    set PASS=*******
    set PKEY_8_c=privatekey.pkcs8
    set PKEY_64_c=privatekey.b64
    set CERT_64_c=cert.cer
    set CERT_12_c=privatecert.cert
    java DumpPrivateKey %KS% %PASS% %ALIAS%> %PKEY_8_c%
    echo -----BEGIN PRIVATE KEY-----> %PKEY_64_c%
    openssl enc -in %PKEY_8_c% -a>> %PKEY_64_c%
    echo.-----END PRIVATE KEY----->> %PKEY_64_c%
    echo.>> %PKEY_64_c%
    with DumpPrivateKey:
    import java.io.FileInputStream;
    import java.security.KeyStore;
    import java.security.Key;
    public class DumpPrivateKey {
    //param 0:keystore, 1:passwd, 2: alias
            static public void main(String[] args) {
                    try {
                            KeyStore ks = KeyStore.getInstance("jks");
                            ks.load(new FileInputStream(args[0]),
                                     args[1].toCharArray());
                            Key key = ks.getKey(args[2],
                                     args[1].toCharArray());
                            System.out.write(key.getEncoded());
                    } catch (Exception e) {
                            e.printStackTrace();
    }

  • J2ME dictionary code with errors

    Hi,
    i'm getting headache looking for error. im new to J2ME so i don't really understand the real problem. Please healp me to correct the code. i would appreciate very much helps from anyone. Thanks and please help!
    code:
    package util;
    import java.util.*;
    import java.io.*;
    class Word {
    String eng;
    String rus;
    int count;
    public class Dictionary {
    static boolean LARGE_DICTIONARY = true;
    static final int FREQUENCY = LARGE_DICTIONARY ? 0 : 3;
    static final int MAX_LENGTH = LARGE_DICTIONARY ? 64 : 25;
    static final int MAX_FILE_SIZE = 16*1024;
    static int split(int[] words, int[] bestParts, int[] currParts, int offs, int partNo, int minWords) {
    if (++partNo < currParts.length) {
    for (int i = offs+1; i < words.length; i++) {
    currParts[partNo-1] = i;
    minWords = split(words, bestParts, currParts, i, partNo, minWords);
    } else {
    int maxWords = 0;
    for (int i = 0, j = 0; i < currParts.length; i++) {
    int nWords = 0;
    while (j < currParts) {
    nWords += words[j++];
    if (nWords > maxWords) {
    maxWords = nWords;
    if (maxWords < minWords) {
    System.arraycopy(currParts, 0, bestParts, 0, currParts.length);
    minWords = maxWords;
    return minWords;
    public static void main(String[] args) throws Exception {
         BufferedReader in = new BufferedReader(new FileReader("Mueller7GPL.win"));
         String line;
         TreeMap hash = new TreeMap();
    nextLine:
         while ((line = in.readLine()) != null) {
         int i = line.indexOf(' ');
         if (i > 1) {
    for (int j = 0; j < i; j++) {
    char ch = line.charAt(j);
    if (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z')) {
    continue nextLine;
              Word word = new Word();
              word.eng = line.substring(0, i).toLowerCase();
              boolean firstChar = true;
              int nBrackets = 0;
              StringBuffer buf = new StringBuffer();
              boolean skip = false;
              while (++i < line.length()) {
              char ch = line.charAt(i);
              switch (ch) {
              case '{':
              case '(':
              case '[':
                   nBrackets += 1;
                   continue;
              case '}':
              case ')':
              case ']':
                   nBrackets -= 1;
                   continue;
              case '_':
                   skip = true;
                   continue;
              case ' ':
                   skip = false;
                   if (!firstChar && nBrackets == 0) {
                   buf.append(' ');
                   continue;
              default:
                   if (!skip && nBrackets == 0) {
                   if (Character.isLetter(ch) && ch > 'z') {
                        firstChar = false;
                        buf.append(ch);
                   } else if (!firstChar) {
                        word.rus = buf.toString().trim();
                        int len = word.rus.length();
                        if (len > 2 && len <= MAX_LENGTH ) {
    if (hash.get(word.eng) == null) {
    hash.put(word.eng, word);
                        continue nextLine;
    if (FREQUENCY != 0) {
    byte[] buf = new byte[1025*1024];
    int rc;
    FileInputStream fs = new FileInputStream("samples.txt");
    while ((rc = fs.read(buf)) > 0) {
    for (int i = 0; i < rc; i++) {
    int j = i;
    char ch;
    while (j < rc && (((ch = (char)buf[j]) >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) {
    j += 1;
    if (j > i) {
    String key = new String(buf, i, j-i).toLowerCase();
    Word word = (Word)hash.get(key);
    if (word != null) {
    word.count += 1;
    i = j;
    if (args.length > 0) {
    int nParts = Integer.parseInt(args[0]);
    int partNo = Integer.parseInt(args[1]);
    Iterator iterator = hash.values().iterator();
    char firstLetter = '\0';
    int[] words = new int[26];
    int i = -1;
    while (iterator.hasNext()) {
    Word word = (Word)iterator.next();
    if (word.eng.charAt(0) != firstLetter) {
    firstLetter = word.eng.charAt(0);
    i += 1;
    words[i] += 1;
    int[] currParts = new int[nParts];
    int[] bestParts = new int[nParts];
    currParts[nParts-1] = words.length;
    split(words, bestParts, currParts, 0, 0, Integer.MAX_VALUE);
    iterator = hash.values().iterator();
    i = 0;
    if (partNo > 1) {
    for (int n = bestParts[partNo-2]; i < n; i++) {
    for (int j = words[i]; --j >= 0;) {
    iterator.next();
    TreeMap subset = new TreeMap();
    for (int n = bestParts[partNo-1]; i < n; i++) {
    for (int j = words[i]; --j >= 0;) {
    Word word = (Word)iterator.next();
    subset.put(word.eng, word);
    hash = subset;
         FileOutputStream index = new FileOutputStream("dictionary.idx");
         FileOutputStream out = new FileOutputStream("volume.1");
         Iterator iterator = hash.values().iterator();
         int n = 0;
         int size = 0;
         int totalSize = 0;
    int id = 1;
    String prevWord = null;
    StringBuffer ib = new StringBuffer();
         while (iterator.hasNext()) {
         Word word = (Word)iterator.next();
         if (word.count >= FREQUENCY) {
              StringBuffer sb = new StringBuffer();
    String thisWord = word.eng;
    if (prevWord == null) {
    ib.append(thisWord);
    ib.append(':');
    sb.append(thisWord);
    } else {
    int prefix;
    int len = thisWord.length() > prevWord.length() ? prevWord.length() : thisWord.length();
    if (len > 9) {
    len = 9;
    for (prefix = 0; prefix < len && thisWord.charAt(prefix) == prevWord.charAt(prefix); prefix++);
    if (prefix > 0) {
    sb.append((char)(prefix + '0'));
    sb.append(thisWord.substring(prefix));
    } else {
    sb.append(thisWord);
              sb.append(':');
              sb.append(word.rus);
              //sb.append('\r');
              sb.append('\n');
              byte[] bytes = sb.toString().getBytes();
    if (size + bytes.length > MAX_FILE_SIZE) {
    ib.append(prevWord);
    ib.append('\n');
    index.write(ib.toString().getBytes());
    ib = new StringBuffer();
    ib.append(thisWord);
    ib.append(':');
    out.close();
    out = new FileOutputStream("volume." + ++id);
    size = 0;
              size += bytes.length;
    totalSize += bytes.length;
              n += 1;
    prevWord = thisWord;
              out.write(bytes);
         out.close();
    ib.append(prevWord);
    ib.append('\n');
    index.write(ib.toString().getBytes());
    index.close();
         System.out.println("Words " + n + ", size " + totalSize);

    Can some one take a look at this code and tell me how to get all my jlabels to line up alone side their jtf.
    Because it looks like this the picture in the attached file and this is the code for it:
    public customerPanel()
    // Set the panel with line border
    setBorder(new BevelBorder(BevelBorder.RAISED));
    // Panel p1 for holding labels Name, Street, and City
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(5, 1));
    p1.add(new JLabel("Registration Number:"));
    p1.add(new JLabel("Seating Capacity:"));
    p1.add(new JLabel("Engine Size:"));
    p1.add(new JLabel("Start date of hire"));
    p1.add(new JLabel("Duration of hire"));
    JPanel p2 = new JPanel();
    p2.setLayout(new GridLayout(5, 1));
    p2.add(jtfRegistrationnumber);
    p2.add(jtfSeatingcapacity);
    p2.add(jtfEnginesize);
    p2.add(jtfStartdateofhire);
    p2.add(jtfDurationofhire);
    //JPanel p3 = new JPanel();
    //p3.add(p1, BorderLayout.WEST);
    //p3.add(p2, BorderLayout.NORTH);
    JPanel p4 = new JPanel();
    p4.setLayout(new GridLayout(4, 1));
    p4.add(new JLabel("Manufacture:"));
    p4.add(new JLabel("Model:"));
    p4.add(new JLabel("Mileage:"));
    p4.add(new JLabel("Charge:"));
    JPanel p5 = new JPanel();
    p5.setLayout(new GridLayout(4, 1));
    p5.add(jtfManufacture);
    p5.add(jtfModel);
    p5.add(jtfMileage);
    p5.add(jtfCharge);
    // JPanel p6 = new JPanel();
    // p6.setLayout(new BorderLayout());
    // p6.add(p4, BorderLayout.SOUTH);
    // p6.add(p5, BorderLayout.EAST);
    // Place p1 and p4 into CustomerPanel
    setLayout(new BorderLayout());
    add(p1, BorderLayout.WEST);
    add(p2, BorderLayout.NORTH);
    add(p4, BorderLayout.SOUTH);
    add(p5, BorderLayout.EAST);
    So could someone please help me and correct my code so that each text lable is lined up next to its jtf java text field.

  • J2ME Extentions

    Hi I got some trouble with the j2me extentions :
    1.- I have see the online page to add the j2me extentions but
    when I set the tools script location and try to run it it's
    didn't work.
    2. When I create a new project (fellow the demo) I get the following error message error :
    jdexec cmd.exe /c C:\jdev903_pre\jdev\bin_j2me\bin\Sun\makeMIDlet C:\jdev903_pre\jdev\bin_j2me\bin\Sun C:\WTK104 C:\jdev903_pre\jdk\bin TestSuite C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\CLASSES.j2meAddin C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\IMAGES.j2meAddin C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\MANIFEST.j2meAddin C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\JAR2ADD.j2meAddin Debug
    MIDlet generation from Oracle9i JDeveloper
    Working for TestSuite in "C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src" with "C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\CLASSES.j2meAddin" icon "C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\IMAGES.j2meAddin" and "C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\MANIFEST.j2meAddin", plus "C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\JAR2ADD.j2meAddin"
    java.io.FileNotFoundException: C:\Documents (Le fichier spicifii est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
              native code
         void java.io.FileInputStream.<init>(java.lang.String)
              FileInputStream.java:64
         void java.io.FileReader.<init>(java.lang.String)
              FileReader.java:38
         void makeUtil.makeExtraCP(java.lang.String, java.lang.String, java.lang.String)
              makeUtil.java:55
         void makeUtil.main(java.lang.String[])
              makeUtil.java:129
    'out.bat' n'est pas reconnu en tant que commande interne
    ou externe, un programme excutable ou un fichier de commandes.
    Impossible de trouver C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\out.bat
    Compiling with Debug Option
    java.io.FileNotFoundException: C:\Documents (Le fichier spicifii est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
              native code
         void java.io.FileInputStream.<init>(java.lang.String)
              FileInputStream.java:64
         void java.io.FileReader.<init>(java.lang.String)
              FileReader.java:38
         void makeUtil.makeCompile(java.lang.String, java.lang.String, java.lang.String)
              makeUtil.java:32
         void makeUtil.main(java.lang.String[])
              makeUtil.java:123
    'out.bat' n'est pas reconnu en tant que commande interne
    ou externe, un programme excutable ou un fichier de commandes.
    Impossible de trouver C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\out.bat
    java.io.FileNotFoundException: C:\Documents (Le fichier spicifii est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
              native code
         void java.io.FileInputStream.<init>(java.lang.String)
              FileInputStream.java:64
         void java.io.FileReader.<init>(java.lang.String)
              FileReader.java:38
         void makeUtil.makeLibs(java.lang.String, java.lang.String, java.lang.String)
              makeUtil.java:100
         void makeUtil.main(java.lang.String[])
              makeUtil.java:127
    'out.bat' n'est pas reconnu en tant que commande interne
    ou externe, un programme excutable ou un fichier de commandes.
    Impossible de trouver C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\tmp\out.bat
    Preverifying
    Making jar file
    .\* : fichier ou ripertoire introuvable
    java.io.FileNotFoundException: C:\Documents (Le fichier spicifii est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
              native code
         void java.io.FileInputStream.<init>(java.lang.String)
              FileInputStream.java:64
         void java.io.FileReader.<init>(java.lang.String)
              FileReader.java:38
         void makeUtil.makeImages(java.lang.String, java.lang.String, java.lang.String)
              makeUtil.java:78
         void makeUtil.main(java.lang.String[])
              makeUtil.java:125
    'out.bat' n'est pas reconnu en tant que commande interne
    ou externe, un programme excutable ou un fichier de commandes.
    Making jad file
    Impossible de trouver C:\Documents and Settings\alexj.UNIVERS\Bureau\Test\Project1\src\out.bat
    **Warning: Using RELATIVE flavor for MIDlet-Jar-URL
    Finished
    thanks in advance
    alexj

    Bonjour Alex!
    Carefully avoid the blanks in files and directory names! That should be the problem!!!
    Merci windows!
    Vous pouvez me contacter directement en cas de probleme ou de recidive a [email protected]
    C'est moi qui ai ecrit l'extension, donc je serai a meme de prendre vos questions et remarques en consideration...
    Best regards,
    Olivier

  • Trouble with J2ME, Wireless toolkit, MakeMIDlet.

    Hallo...
    I can't get JDeveloper to create the Midlet package.
    I've I have installed and set up the WTK20 in the J2ME configuration.
    I've also made the changes to .jar files in the makeMIDlet.bat.
    I get the following error:
    MIDlet generation from Oracle9i JDeveloper
    Working for Just-Eat in "C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src" with "C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\CLASSES.j2meAddin" icon "C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\IMAGES.j2meAddin" and "C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\MANIFEST.j2meAddin", plus "C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\JAR2ADD.j2meAddin"
    java.io.FileNotFoundException: C:\Documents (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at java.io.FileReader.<init>(FileReader.java:41)
         at makeUtil.makeExtraCP(makeUtil.java:55)
         at makeUtil.main(makeUtil.java:129)
    'out.bat' is not recognized as an internal or external command,
    operable program or batch file.
    Could Not Find C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\out.bat
    Compiling with NoDebug Option
    java.io.FileNotFoundException: C:\Documents (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at java.io.FileReader.<init>(FileReader.java:41)
         at makeUtil.makeCompile(makeUtil.java:32)
         at makeUtil.main(makeUtil.java:123)
    'out.bat' is not recognized as an internal or external command,
    operable program or batch file.
    Could Not Find C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\out.bat
    java.io.FileNotFoundException: C:\Documents (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at java.io.FileReader.<init>(FileReader.java:41)
         at makeUtil.makeLibs(makeUtil.java:100)
         at makeUtil.main(makeUtil.java:127)
    'out.bat' is not recognized as an internal or external command,
    operable program or batch file.
    Could Not Find C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\tmp\out.bat
    Preverifying
    Making jar file
    .\* : no such file or directory
    java.io.FileNotFoundException: C:\Documents (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at java.io.FileReader.<init>(FileReader.java:41)
         at makeUtil.makeImages(makeUtil.java:78)
         at makeUtil.main(makeUtil.java:125)
    'out.bat' is not recognized as an internal or external command,
    operable program or batch file.
    Could Not Find C:\Documents and Settings\SodiumLight\Desktop\JustEat\Project\src\out.bat
    Making jad file
    Finished
    The strange part is that the same copy of JDeveloper works fine on another system...
    I hope someout out there can help me out...
    Regards Thomas Rolskov
    [email protected]

    HI Friend:
    You install jdk1.5.try it!

  • File and FileInputStream problem

    Hi all
    I have downloaded from developpez.com a sample code to zip files. I modified it a bit to suit with my needs, and when I launched it, there was an exception. So I commented all the lines except for the first executable one; and when it succeeds then I uncomment the next executable line; and so on. When I arrived at the FileInputStream line , the exception raised. When I looked at the code, it seemed normal. So I want help how to solve it. Here is the code with the last executable line uncommented, and the exception stack :
    // Copyright (c) 2001
    package pack_zip;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import oracle.jdeveloper.layout.*;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.text.*;
    * A Swing-based top level window class.
    * <P>
    * @author a
    public class fzip extends JFrame implements ActionListener{
    JPanel jPanel1 = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    JTextField szdir = new JTextField();
    JButton btn = new JButton();
    JButton bzip = new JButton();
         * Taille générique du tampon en lecture et écriture
    static final int BUFFER = 2048;
    * Constructs a new instance.
    public fzip() {
    super("Test zip");
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    * Initializes the state of this instance.
    private void jbInit() throws Exception {
    this.getContentPane().setLayout(xYLayout1);
         this.setSize(new Dimension(400, 300));
    btn.setText("btn");
    btn.setActionCommand("browse");
    btn.setLabel("Browse ...");
    btn.setFont(new Font("Dialog", 0, 14));
    bzip.setText("bzip");
    bzip.setActionCommand("zipper");
    bzip.setLabel("Zipper");
    bzip.setFont(new Font("Dialog", 0, 14));
    btn.addActionListener(this);
    bzip.addActionListener(this);
    bzip.setEnabled(false);
         this.getContentPane().add(jPanel1, new XYConstraints(0, 0, -1, -1));
    this.getContentPane().add(szdir, new XYConstraints(23, 28, 252, 35));
    this.getContentPane().add(btn, new XYConstraints(279, 28, 103, 38));
    this.getContentPane().add(bzip, new XYConstraints(128, 71, 103, 38));
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand() == "browse")
    FileDialog fd = new FileDialog(this);
    fd.setVisible(true);
    szdir.setText(fd.getDirectory());
    bzip.setEnabled(true);
    else
              * Compression
         try {
              // création d'un flux d'écriture sur fichier
         FileOutputStream dest = new FileOutputStream("Test_archive.zip");
              // calcul du checksum : Adler32 (plus rapide) ou CRC32
         CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());
              // création d'un buffer d'écriture
         BufferedOutputStream buff = new BufferedOutputStream(checksum);
              // création d'un flux d'écriture Zip
         ZipOutputStream out = new ZipOutputStream(buff);
         // spécification de la méthode de compression
         out.setMethod(ZipOutputStream.DEFLATED);
              // spécifier la qualité de la compression 0..9
         out.setLevel(Deflater.BEST_COMPRESSION);
         // buffer temporaire des données à écriture dans le flux de sortie
         byte data[] = new byte[BUFFER];
              // extraction de la liste des fichiers du répertoire courant
         File f = new File(szdir.getText());
         String files[] = f.list();
              // pour chacun des fichiers de la liste
         for (int i=0; i<files.length; i++) {
                   // en afficher le nom
              System.out.println("Adding: "+files);
    // création d'un flux de lecture
    FileInputStream fi = new FileInputStream(files[i]);
    /* // création d'un tampon de lecture sur ce flux
    BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
    // création d'en entrée Zip pour ce fichier
    ZipEntry entry = new ZipEntry(files[i]);
    // ajout de cette entrée dans le flux d'écriture de l'archive Zip
    out.putNextEntry(entry);
    // écriture du fichier par paquet de BUFFER octets
    // dans le flux d'écriture
    int count;
    while((count = buffi.read(data, 0, BUFFER)) != -1) {
              out.write(data, 0, count);
                   // Close the current entry
    out.closeEntry();
    // fermeture du flux de lecture
              buffi.close();*/
    /*     // fermeture du flux d'écriture
         out.close();
         buff.close();
         checksum.close();
         dest.close();
         System.out.println("checksum: " + checksum.getChecksum().getValue());*/
         // traitement de toute exception
    catch(Exception ex) {
              ex.printStackTrace();
    And here is the error stack :
    "D:\jdev32\java1.2\jre\bin\javaw.exe" -mx50m -classpath "D:\jdev32\myclasses;D:\jdev32\lib\jdev-rt.zip;D:\jdev32\jdbc\lib\oracle8.1.7\classes12.zip;D:\jdev32\lib\connectionmanager.zip;D:\jdev32\lib\jbcl2.0.zip;D:\jdev32\lib\jgl3.1.0.jar;D:\jdev32\java1.2\jre\lib\rt.jar" pack_zip.czip
    Adding: accueil188.cfm
    java.io.FileNotFoundException: accueil188.cfm (Le fichier spécifié est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
         void java.io.FileInputStream.<init>(java.lang.String)
         void pack_zip.fzip.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.setPressed(boolean)
         void javax.swing.plaf.basic.BasicButtonListener.mouseReleased(java.awt.event.MouseEvent)
         void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
         void java.awt.Component.processEvent(java.awt.AWTEvent)
         void java.awt.Container.processEvent(java.awt.AWTEvent)
         void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
         boolean java.awt.EventDispatchThread.pumpOneEvent()
         void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
         void java.awt.EventDispatchThread.run()
    Thank you very much

    One easy way to send a file through RMI is to read all bytes of a file to a byte array and send this array as a parameter of a remote method. But of course you may have problems with memory when you send large files. The receive is simillary.
    Other way is to split the file and getting slices of the file, sending slices and re-assemble at destination. This assume that the file isn't changed through the full transfering is concluded.
    I hope these could help you.

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • Send email from j2me through servlet

    Hi people,
    i hope you can help me because i am new in network programming.
    I am trying to send email from j2me to googlemail account I have 2 classes EmailMidlet (which has been tested with wireless Toolkit 2.5.2 and it works) and the second class is the servlet-class named EmailServlet:
    when i call the EmailServlet, i get on the console:
    Server: 220 mx.google.com ESMTP g28sm19313024fkg.21
    Server: 250 mx.google.com at your service
    this is the code of my EmailServlet
    import java.io.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.text.*;
    import java.util.Date;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class EmailServlet extends HttpServlet {
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws IOException, ServletException {
          System.out.println("____emailservlet.doPost");
          response.setContentType("text/plain");
          PrintWriter out = response.getWriter();
          System.out.println("______________________________");
          out.println();
          String to = request.getParameter("to");
          System.out.println("____________________________to" + to);
          String subject = request.getParameter("subject");
          String msg = request.getParameter("msg");
          // construct an instance of EmailSender
          System.out.println("servlet_to" + to);
          send("[email protected]", to, subject, msg);
          out.println("mail sent....");
       public void send(String from, String to, String subject, String msg) {
          Socket smtpSocket = null;
          DataOutputStream os = null;
          DataInputStream is = null;
          try {
             smtpSocket = new Socket("smtp.googlemail.com", 25);
             os = new DataOutputStream(smtpSocket.getOutputStream());
             is = new DataInputStream(smtpSocket.getInputStream());
          } catch (UnknownHostException e) {
             System.err.println("Don't know about host: hostname");
          } catch (IOException e) {
             System.err
                   .println("Couldn't get I/O for the connection to: hostname");
          if (smtpSocket != null && os != null && is != null) {
             try {
                os.writeBytes("HELO there" + "\r\n");
                os.writeBytes("MAIL FROM: " + from + "\r\n");
                os.writeBytes("RCPT TO: " + to + "\r\n");
                os.writeBytes("DATA\r\n");
                os.writeBytes("Date: " + new Date() + "\r\n"); // stamp the msg
                                                    // with date
                os.writeBytes("From: " + from + "\r\n");
                os.writeBytes("To: " + to + "\r\n");
                os.writeBytes("Subject: " + subject + "\r\n");
                os.writeBytes(msg + "\r\n"); // message body
                os.writeBytes(".\r\n");
                os.writeBytes("QUIT\r\n");
                // debugging
                String responseLine;
                while ((responseLine = is.readLine()) != null) {
                   System.out.println("Server: " + responseLine);
                   if (responseLine.indexOf("delivery") != -1) {
                      break;
                os.close();
                is.close();
                smtpSocket.close();
             } catch (UnknownHostException e) {
                System.err.println("Trying to connect to unknown host: " + e);
             } catch (IOException e) {
                System.err.println("IOException: " + e);
       } 1.when i print "to" in EmailServlet also:
      String to = request.getParameter("to");
          System.out.println("____________________________to" + to);  it show null on the console :confused:
    2. ist this right in case of googlemail.com?
      smtpSocket = new Socket("smtp.googlemail.com", 25);  I would be very grateful if somebody can help me.

    jackofall
    Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    I'm locking this thread now.
    db

  • J2me and java card, need help to communicate

    we are trying to put together a reader to read smartcards using j2me and we figure that it would be easiest if we could develop it to work with java cards rather than standard smart cards, the problem is we get garbage when we communicate to it, the chip sends us crap, any suggestions what might be wrong, any calls we might be missing, has anyone worked with j2me and java cards or smart cards, any help would be appreciated.
    einar

    .... reader app and the ME behind it .... smells like mobile ....
    First of all - if you want to have one mobile application running on this just make sure that whatever is written in ME can use drivers from the reader chip ....
    Workin on the PC is something completely different. There was one good example how to develop one host application in Java provided with the JCOP tools long ago ... I don't know if this is now in the new Eclipse tools.
    But - there was a small API provided that can give you good hints what to do - and - once you have it on the reader side - you can easily integrate ME methods with this ...

  • Image Processing in j2me

    Hi All,
    I want to do image processing in mobile application(j2me).
    But there are not enough java packages in mobile environment.
    How to do it please let me know if any body knows.
    Thanks.

    brightness: convert every RGB pixel to HSB -> increase luminance by constant value -> convert back to RGB
    contrast: convert every RGB pixel to HSB -> multiply luminance by constant value-> convert back to RGB
    You can also do both in one go.

  • UTF-8 encoding in J2ME

    Hello,
    I'm currently developing J2ME application for downloading bus schedules.
    The data that I download is in polish language (eg. bus directions, stop names etc). These are xml files generated by a php script encoded in UTF-8.
    The problem is that I don't know how to display that properly, so that all the polish characters are what they're supposed to be.
    Some of my code for downloading content:
    String getXML(String url)
            HttpConnection cn = null;
            InputStream str = null;
            //DataInputStream strd = null;
            StringBuffer sb = null;
            try
                int code;
                cn = (HttpConnection) Connector.open(url);
                code = cn.getResponseCode();
                if (code == HttpConnection.HTTP_OK)
                    str = cn.openInputStream();
                    // strd = new DataInputStream(str);
                    sb = new StringBuffer();
                    InputStreamReader r = new InputStreamReader(str, "UTF-8");
                    int total = 0;
                    int read = 0;
                    while ((read = r.read()) >= 0)
                        total++;
                        sb.append((char) read);
                    return sb.toString();
                else
                    throw new Exception("Nie uda&#322;o si&#281; po&#322;&#261;czy&#263; z serwerem");
            catch (Exception e)
                return null;
            finally
                try
                    if (str != null)
                        str.close();
                    if (cn != null)
                        cn.close();
                catch (Exception e)
        }And parsing it:
    InputStreamReader reader = null;
                    String xml = getScheduleXML(getSel_Line(), null, null);
                    ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes());
                    reader = new InputStreamReader(stream, "UTF-8");
                    parser.setInput(reader);
                    while (parser.next() != KXmlParser.END_DOCUMENT)
                        if ((parser.getEventType() == KXmlParser.START_TAG) && (parser.getName().equalsIgnoreCase("direction")))
                                String d = (String) parser.getAttributeValue(0);
                                v.addElement(d);
                                String d2 = (String) parser.getAttributeValue(1);
                                v2.addElement(d2);
                    }What do I do wrong? What is missing?

    Problem solved. I had to add "UTF-8" parameter to getBytes method.

  • How to send sms from gsm modem(AT commands) to j2me application(not inbox)

    hi
    i want to send sms from gsm modem to a j2me application, for this to happen i have to send sms to a specific port in which j2me application is running.when i m trying to send sms from modem it doesnt go to application it goes to inbox.
    is it related to udh settings if yes then how do i set port no in settings?if no what are the other ways.

    Hi Vignesh,
    Might be you can call ActiveX or DLL objects of the software installed for modem from LabVIEW, if it is unblocked.
    Have a  look on the link > http://zone.ni.com/devzone/cda/tut/p/id/2983
    CLA 2014
    CCVID 2014

  • Cant pass file from a dir to fileinputstream()

    hi !
    i am stuck here ..please help.
    I have an application that creates a dir called temp in home directory . and and a file which is named in following format. for example
    080718002220.txt
    i.e. systemdate.ext type . Since this files are created in real time and has no specific file name .How would i pass it to fileinputstream() .
    Note : only one file will be there at a time but has no fixed file name as is mentioned in tutorials.
    Is there a way to pass either the naming pattern or file extention to do select the file .??

    A hint: you can peruse a directory for its contents.
    A sidenote: *.* denotes the working directory, which might be different from the home directory.

  • Problem with Display.setCurrentItem() using J2ME-Polish

    Hi,
    I am fairly new to J2ME-polish and have encountered a situation that I am having a problem with. I am loading a form with a number of String Items. When I display the form I would like to focus to the last String Item that has been placed on the form. I have been using Display.setCurrentItem() in J2ME but when I try using it in J2ME-Polish I receive this message :"de.enough.polish.ui.Screen (3022): Screen: unable to focus item (did not find it in the container or is not activatable ) "
    Below is a snippet of my code.
            // si14 in a StringItem defined earlier in the code
            // It is the last stringItem placed into the form
            form.append(si14);
            display = Display.getDisplay(this);
         display.setCurrent(form);
         display.setCurrentItem(form.get(0));Thanks

    http://forums.sun.com/thread.jspa?threadID=686256&messageID=10864566

  • How to get the Mobile information by using J2ME application

    hi all,
    I am lakshman.I am developing an application in j2me,I want my program compatible to all mobile devices.
    I want to know properties and the device information with the help of a j2me application.I got the information with the help of System.getProperty(String).I found some of the information like sms,videocapture,and some of the values and the variables ... in the following
    platform...null
    encoding...ISO-8859-1
    configuration...CLDC-1.0
    profile...MIDP-2.0
    locale...null
    fileconnection...1.0
    comport...null
    hostname...iwmc-07
    sms...null
    smartcard...null
    location version...null
    sip version...null
    m3gversion...null
    mms...null
    videocapture...false
    videoencoding...null
    snapshotencoding...encoding=png encoding=jpeg encoding=gif encoding=bmp
    audioencoding...null
    supaudcap...false
    suprecod...false
    supmixing...false
    mediaversion...1.1
    streamcont...null
    I want to know these are the only variables or is there are lot...
    Now my question is I want to get the information of the service provider and also the present location that the mobile was present.I think there was some method to get that ...I want to get what firmware it was using .
    Can anybody tell me that way and also the package to get the information
    thanks in advance
    lakshman

    hi all,
    I am lakshman,I found the answer for my question,By using the Location API(jsr179).It was not include in the WTK2.2.for that i have downloaded the WTK2.3 then i have implemented the location api in the application and it was working.
    And I have the following warning...
    Warning: To avoid potential deadlock, operations that may block, such as
    networking, should be performed in a different thread than the
    commandAction() handler.
    I am running the application from my Emulator(by using the default color phone).I have to check that in the device.
    Can any body please give me the way to fix that,i want to test my application from my emulator is that is possible if possible ...how?.what is the procedure to implement..
    thanks in advance

Maybe you are looking for