Problem with FileNotFoundException

Hi. Sometimes in my application i have problems with FileNotFoundException, but file which i want to open exists. In the documentation I found that:"It will also be thrown by these constructors if the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing." What can be another reason that the file is inaccessible?

EJP wrote:
That doesn't happen unless the file is currently in use ...I would have to dissagree with you there. Not frequently, but on occasioin, I have had windows just not release a lock that is has on a file. I've had this happen with various editors--Word and Notepad are ones that recently come to mind. It has also happened to me doing a copy from one folder to another. Windows Media Player has also expressed a problem and also Excel and Access. I have had these problems in Windows 7, XP, and other previous Windows versions. And please do not think this is limited to accessing a file with Java--it has expressed in various MS development tools and even just using MS products--no programming outside of the shrink wrap MS product was used.

Similar Messages

  • Problem with GDS - FileNotFoundException

    I get the following ERROR under heavy load in the server.log when "converting" xml to pdf(generatePDFOutput). Running lc es2(cluster), jboss 4.3, suse linux 11 sp2.
    2014-09-11 15:35:32,950 ERROR [com.adobe.idp.Document] DOCS001: Unexpected exception. An exception while handling a remote request.
    java.io.FileNotFoundException: /srv/global_document_storage/docm1410442494924/b61c1af1ccf663bd8a37be64903d0388 (No such file or directory)
      at java.io.RandomAccessFile.open(Native Method)
      at java.io.RandomAccessFile.<init>(RandomAccessFile.java:216)
      at com.adobe.util.FileUtil.randomAccessRead(FileUtil.java:297)
      at com.adobe.idp.DocumentPullServant.readData(DocumentPullServant.java:168)
      at com.adobe.idp.DocumentPullServant.pullContent(DocumentPullServant.java:154)
      at com.adobe.idp.IDocumentPullServantPOA._invoke(IDocumentPullServantPOA.java:42)
      at org.jacorb.poa.RequestProcessor.invokeOperation(Unknown Source)
      at org.jacorb.poa.RequestProcessor.process(Unknown Source)
      at org.jacorb.poa.RequestProcessor.run(Unknown Source)
    Any idea? No luck with increasing the document disposal timeout or sweep interval...

    Our pdf-files is about the size of 130 kb.
    With the current configuration we have set the document max-inline-size to 512 kb. Now the FileNotFoundException to the GDS has disapeared. But i still wonder why this error was shown when we used the GDS instead on the memory.....
    Could it be problem with Synchronizing clock times in our cluster..?
    Now and then we have another FileNotFoundException ERROR  in the tmp-directory. In what way are LC using this directory..?
    2014-09-18 23:33:58,067 ERROR [com.adobe.idp.Document] DOCS001: Unexpected exception. While doing first time passivation for a document..
    com.adobe.idp.DocumentError: java.io.FileNotFoundException: /tmp/AdobeDocumentStorage/local/docm1411075483830/c694140f75dc873cf6c26afd8e73f57e (No such file or directory)
    at com.adobe.idp.Document.passivateInitData(Document.java:1461)
    at com.adobe.idp.Document.passivate(Document.java:1241)
    at com.adobe.idp.DocumentCallback.handleRemotePassivation(DocumentCallback.java:145)
    at com.adobe.idp.DocumentCallback.handleRemotePassivation2(DocumentCallback.java:189)
    at com.adobe.idp._IDocumentCallbackImplBase._invoke(_IDocumentCallbackImplBase.java:71)
    at org.jacorb.orb.ORB$HandlerWrapper._invoke(Unknown Source)
    at org.jacorb.poa.RequestProcessor.invokeOperation(Unknown Source)
    at org.jacorb.poa.RequestProcessor.process(Unknown Source)
    at org.jacorb.poa.RequestProcessor.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: /tmp/AdobeDocumentStorage/local/docm1411075483830/c694140f75dc873cf6c26afd8e73f57e (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:120)
    at com.adobe.idp.Document.passivateInitData(Document.java:1457)
    ... 8 more

  • Problem with ArrayList

    Hello,
    I am having a problem with a program I am trying to write. The idea of the program is to:
    A) read a list of movies list from a text file
    B) create an object for each movie using the information from the text file
    C) place the objects into an arrayList
    My problem is that when I check my arrayList it seems to only contain multiple copies of the first movie read from the text file. Here is my code
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.io.FileOutputStream;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    public class MovieReader
         PrintWriter outputStream = null;
         public void readFile()
              try
                      BufferedReader in = new BufferedReader(new FileReader("movie.txt"));
                      String str;
                      while ((str = in.readLine()) != null)
                           process(str);
                      in.close();
              catch (IOException e)
                  e.printStackTrace();
         ArrayList <ValidMovie> movieList = new ArrayList<ValidMovie>();
         private void process(String line)
              String[] array = line.split("\t");
              int i = 0;
              for ( i = 0; i < array.length; i++)
                   String tempTitle = array[0];
                   String tempYear = array [1];
                   String tempRating = array [2];
                   String tempFormat = array [3];
                   ValidMovie uuj = new ValidMovie(tempTitle, tempYear, tempRating, tempFormat);
                   movieList.add(uuj);
              System.out.println("item at index 1 is:   " + movieList.get(1));
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         private void writeFile(String [] arrayL)
              String [] arrayWrite = arrayL;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
         public static void main(String[] args)
              MovieReader mv = new MovieReader();
              mv.readFile();
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    }This is the code that creates an object for each movie:
    import java.io.Serializable;
    public class ValidMovie implements Serializable
         private String title;
         private String year;
         private String rating;
         private String format;
         public ValidMovie()
         public ValidMovie(String tTitle, String tYear, String tRating, String tFormat)
              title = tTitle;
              year = tYear;
              rating = tRating;
              format = tFormat;
         //Getters for title, year, rating and format
         public String getTitle ()
              return title;
         public String getYear ()
              return year;
         public String getRating ()
              return rating;
         public String getFormat ()
              return format;
         public String toString ()
              return title + "\t" + year + "\t" + rating + "\t" + format;
    }The following is what I have in the movie.txt file:
    Bamboozled     2000     2     DVD
    What Lies Beneath     2000     1.5     DVD
    Beneath the Planet of the Apes     1970     1     DVD
    You Can Count On Me     2000     3.5     Theater
    And finally this is the result when I run the code:
    item at index 1 is: Bamboozled     2000     2     DVD
    item at index 1 is: Bamboozled     2000     2     DVD
    item at index 1 is: Bamboozled     2000     2     DVD
    item at index 1 is: Bamboozled     2000     2     DVD
    I am sure that it is something simple that I am overlooking but I cannot figure it out. When I change the index in the code:
    System.out.println("item at index 1 is:   " + movieList.get(1));to 0 or 2 or 3 then result is the same, it will just show the first movie in the text file. Any help would be greatly appreciated. Thanks

    Thanks for the reply, it helped but I am now getting 4 of each of the movies after adding you suggestion. This is much better now I just need to figure out why the loop is causing the extra copies. Thanks again :)
    Item 0: Bamboozled     2000     2     DVD
    Item 1: Bamboozled     2000     2     DVD
    Item 2: Bamboozled     2000     2     DVD
    Item 3: Bamboozled     2000     2     DVD
    Item 4: What Lies Beneath     2000     1.5     DVD
    Item 5: What Lies Beneath     2000     1.5     DVD
    Item 6: What Lies Beneath     2000     1.5     DVD
    Item 7: What Lies Beneath     2000     1.5     DVD
    Item 8: Beneath the Planet of the Apes     1970     1     DVD
    Item 9: Beneath the Planet of the Apes     1970     1     DVD
    Item 10: Beneath the Planet of the Apes     1970     1     DVD
    Item 11: Beneath the Planet of the Apes     1970     1     DVD
    Item 12: You Can Count On Me     2000     3.5     Theater
    Item 13: You Can Count On Me     2000     3.5     Theater
    Item 14: You Can Count On Me     2000     3.5     Theater
    Item 15: You Can Count On Me     2000     3.5     Theater

  • Problem with build_samples.bat in java_card_kit-2_1_2

    Hi,
    I have installed jdk1.3.1_20 and have setup java_card_kit-2_1_2. Following the website, I could compile Wallet.java. But some reason the build_samples.bat is not working properly. Looking through the code, when i reach to the line:
    %JAVA_HOME%\bin\jar -xvf %JC21_HOME%\lib\api21.jar (line 46 of the build_samples.bat) it gives me this error:
    java.io.FileNotFoundException: c:\Java\java_card_kit-2_1_2 (Access is denied)
    at java.io.FileInputStream.open (Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:91)
    at java.io.FileInputStream.<init>(FileInputStream.java:54)
    at sun.tools.jar.Main.run(Main.java:181)
    at sun.tools.jar.Main.main(Main.java:899)
    The system cannot find the file specified.
    Why is this happening:
    FYI this is my javacard_env.bat (the file that I start the javacard environment):
    set classpath=.;
    set JAVA_HOME=C:\Java\jdk1.3.1_20
    set path=C:\Java\jdk1.3.1_20\bin;
    set JC21_HOME=c:\Java\java_card_kit-2_1_2
    set path=%path%;%JC21_HOME%\bin;
    set classpath=%classpath%;%JC21_HOME%\lib\api21.jar;
    Can someone please help.
    Regards,
    Zeallous

    I'm actually ok with that part now,
    I'm now having problems with converting Samples section:
    once it reaches the line (whilst running build_samples.bat):
    call %JC21_HOME%\bin\converter -config ..\src\com\sun\javacard\samples\HelloWorld\HelloWorld.opt
    it gives me this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: \lib\apduio/jar;C:\Java\java_card_kit-2_1_2
    I have already put in this as my javacard_env.bat before i ran everything:
    @echo off
    set classpath=.;
    set JAVA_HOME=C:\Java\jdk1.3.1_20
    set path=C:\Java\jdk1.3.1_20\bin;
    set JC21_HOME=C:\Java\java_card_kit-2_1_2
    set path=%path%;%JC21_HOME%\bin;
    set classpath=%classpath%;C:\Java\java_card_kit-2_1_2\lib\api21.jar;%CLASSPATH%;
    set classpath=%classpath%;C:\Java\jdk1.3.1_20\jre\lib\ext\apduio.jar;%CLASSPATH%;
    What is wrong with this?
    Regards,
    Zeallous

  • Problems with SwingWorker and classes in my new job, ;), can you help me?

    Hi all, ;)
    First of all, sorry about my poor English.
    I have a problem with Swing and Threads, I hope you help me (because I'm in the firsts two weeks in my new job)
    I have two classes:
    Form1: Its a JPanel class with JProgressBar and JLabel inside.
    FormularioApplet: (the main) Its a JPanel class with a form1 inside.
    I have to download a file from a server and show the progress of the download in the JProgressBar. To make it I do this:
    In Form1 I make a Thread that update the progress bar and gets the fole from the server.
    In FormularioApplet (the main) I call to the method getDownloadedFile from Form1 to get the File.
    THE PROBLEM:
    The execution of FormularioApplet finishes before the Thread of Form1 (with download the file) download the file. Then, when I call in FormularioApplet the variable with the file an Exception: Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException is generated.
    First main begins his execution, then call to Form1 (a thread) then continues his execution and when the execution is finished ends the execution os Form1 and his thread.
    How can I do for main class call the function and the Thread download his file after main class assign the file of return method?
    How can I pass information froma class include an a main class. Form1 can't send to main (because main class made a Form1 f1 = new Form1()) any information from his end of the execution. I think if Form1 can say to main class that he finishes is job, then main class can gets the file.
    I put in bold the important lines.
    Note: My level of JAVA, you can see, is not elevated.
    THANKS A LOT
    Form1 class:
    package es.cambrabcn.signer.gui;
    import java.awt.HeadlessException;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.StringTokenizer;
    import java.util.Vector;
    import javax.swing.SwingUtilities;
    public class Form1 extends javax.swing.JPanel {
        //Variables relacionadas con la clase original DownloadProgressBar
        private InputStream file;
        private int totalCicles;
        private int totalFiles;
        private int currentProgress;
        private SwingWorker worker;
        private ByteArrayOutputStream byteArray;
        private boolean done;
        /** Creates new form prueba */
        public Form1() {
            initComponents();
            this.byteArray = new ByteArrayOutputStream();
            progressBar.setStringPainted(true);
            //this.totalFiles = totalFiles;
            currentProgress = 0;
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" C�digo Generado ">                         
        private void initComponents() {
            label1 = new javax.swing.JLabel();
            progressBar = new javax.swing.JProgressBar();
            statusLabel = new javax.swing.JLabel();
            setBackground(new java.awt.Color(255, 255, 255));
            setMaximumSize(new java.awt.Dimension(300, 150));
            setMinimumSize(new java.awt.Dimension(300, 150));
            setPreferredSize(new java.awt.Dimension(300, 150));
            label1.setFont(new java.awt.Font("Arial", 1, 18));
            label1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            label1.setText("Barra de progreso");
            statusLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            statusLabel.setText("Cargando");
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, statusLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, progressBar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, label1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(label1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(statusLabel)
                    .addContainerGap(73, Short.MAX_VALUE))
        }// </editor-fold>                       
        // Declaraci�n de variables - no modificar                    
        private javax.swing.JLabel label1;
        private javax.swing.JProgressBar progressBar;
        private javax.swing.JLabel statusLabel;
        // Fin de declaraci�n de variables                  
        public byte[] getDownloadedFile(String documentToSign){
             //Variables locales
             byte puente[] = null;
             try{
                //Leemos el documento a firmar
                StringTokenizer st = new StringTokenizer(documentToSign, ";");
                Vector<URL> fileURL = new Vector<URL>();
                HttpSender sender = new HttpSender(null);
                //Introducimos la lista de URLs de archivos a bajar en el objeto Vector
                for(; st.hasMoreTokens(); fileURL.add(new URL(st.nextToken())));
                //Para cada URL descargaremos un archivo
                for(int i = 0; i < fileURL.size(); i++) {
                    file = sender.getMethod((URL)fileURL.get(i));
                    if(file == null) {
                        Thread.sleep(1000L);
                        throw new RuntimeException("Error descarregant el document a signar.");
                    System.out.println("Form1 Dentro de getDownloadFile, Antes de startDownload()");
                    //Fijamos el valor del n�mero de ciclos que se har�n seg�n el tama�o del fichero
                    this.totalCicles = sender.returnCurrentContentLength() / 1024;
                    this.progressBar.setMaximum(totalCicles);
                    //Modificamos el texto del JLabel seg�n el n�mero de fichero que estemos descargando
                    this.statusLabel.setText((new StringBuilder("Descarregant document ")).append(i + 1).append(" de ").append(fileURL.size()).toString());
                    statusLabel.setAlignmentX(0.5F);
                    *//Iniciamos la descarga del fichero, este m�todo llama internamente a un Thread*
                    *this.startDownload();*
                    *System.out.println("Form1 Dentro de getDownloadFile, Despu�s de startDownload()");*
                    *//if (pane.showProgressDialog() == -1) {*
                    *while (!this.isDone()){*
                        *System.out.println("No est� acabada la descarga");*
                        *if (this.isDone()){*
                            *System.out.println("Thread ACABADO --> Enviamos a puente el archivo");*
                            *puente = this.byteArray.toByteArray();*
                            *System.out.println("Form1 getDownloadFile() tama�o puente: " + puente.length);*
                        *else{*
                            *Thread.sleep(5000L);*
    *//                        throw new RuntimeException("Proc�s de desc�rrega del document a signar cancel�lat.");*
            catch (HeadlessException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("UI: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            catch (MalformedURLException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("CMS: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            catch (HttpSenderException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("CMS: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            catch (InterruptedException e) {
                    //javascript("onSignError", new String[] {
                    //(new StringBuilder("CMS: ")).append(e.getMessage()).toString()});
            e.printStackTrace();
            //System.out.println("Form1 getDownloadFile() tama�o puente: " + puente.length);
            return puente;
        public void updateStatus(final int i){
            Runnable doSetProgressBarValue = new Runnable() {
                public void run() {
                    progressBar.setValue(i);
            SwingUtilities.invokeLater(doSetProgressBarValue);
        public void startDownload() {
            System.out.println("Form1 Inicio startDownload()");
            System.out.println("Form1 Dentro de startDownload, antes de definir la subclase SwingWorker");
            System.out.println(done);
            worker = new SwingWorker() {
                public Object construct() {
                    System.out.println("Form1 Dentro de startDownload, dentro de construct(), Antes de entrar en doWork()");
                    return doWork();
                public void finished() {
                    System.out.println("Form1 Dentro de startDownload, dentro de finished(), Antes de asignar done = true");
                    System.out.println(done);
                    done = true;
                    System.out.println("Form1 Dentro de startDownload, dentro de finished(), Despu�s de asignar done = true");
                    System.out.println(done);
                    statusLabel.setText("Completado, tama�o del archivo: " + (byteArray.size() / 1024) + "KB");
            System.out.println("Form1 Dentro de startDownload, antes de worker.start()");
            worker.start();
            System.out.println("Form1 Dentro de startDownload, antes de salir de startDownload");
            System.out.println(done);
            System.out.println("Form1 Dentro de startDownload, despu�s de worker.start()");
         * M�todo doWork()
         * Este m�todo descarga por partes el archivo que es necesario descargar, adem�s de actualizar
         * la barra de carga del proceso de carga de la GUI.
        public Object doWork() {
            System.out.println("Form1 doWork() this.byteArray.size(): " + this.byteArray.size());
            try {
                byte buffer[] = new byte[1024];
                for(int c = 0; (c = this.file.read(buffer)) > 0;) {
                    this.currentProgress++;
                    updateStatus(this.currentProgress);
                    this.byteArray.write(buffer, 0, c);
                this.byteArray.flush();
                this.file.close();
                this.currentProgress = totalCicles;
                updateStatus(this.currentProgress);
            } catch(IOException e) {
                e.printStackTrace();
            System.out.println("Form1 doWork() FINAL this.byteArray.size(): " + this.byteArray.size());
            //done = true;
            System.out.println("AHORA DONE = TRUE");
            return "Done";
        public boolean isDone() {
            return this.done;
    FormularioApplet class (main)
    package es.cambrabcn.signer.gui;
    import java.awt.Color;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.net.URL;
    import java.security.Security;
    import java.util.StringTokenizer;
    import java.util.Vector;
    import javax.swing.SwingUtilities;
    import netscape.javascript.JSObject;
    import org.bouncycastle.jce.provider.BouncyCastleProvider;
    import sun.security.provider.Sun;
    import be.cardon.cryptoapi.provider.CryptoAPIProvider;
    public class FormularioApplet extends java.applet.Applet {
        //Variables globales
        int paso = 0;
        private static final String JS_ONLOAD = "onLoad";
        private static final String JS_ONLOADERROR = "onLoadError";
        private static final int SIGNATURE_PDF = 1;
        private static final int SIGNATURE_XML = 2;
        //private String signButtonValue;
        private int signatureType;
        private String documentToSign;
        private String pdfSignatureField;
        private Vector<String> outputFilename;
        private Color appletBackground = new Color(255, 255, 255);
        private Vector<byte[]> ftbsigned;
         * Initializes the applet FormularioApplet
        public void init(){
            try {
                SwingUtilities.invokeLater(new Runnable() {
                //SwingUtilities.invokeAndWait(new Runnable() {
                //java.awt.EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        try{
                            readParameters();
                            initComponents();
                        catch(FileNotFoundException e){
                            javascript(JS_ONLOADERROR, new String[] {
                                (new StringBuilder("Init: ")).append(e.getMessage()).toString()});
                            e.printStackTrace();                       
                        catch(IOException e) {
                            javascript(JS_ONLOADERROR, new String[] {
                                (new StringBuilder("Init: ")).append(e.getMessage()).toString()});
                            e.printStackTrace();
            catch (Exception e) {
                javascript(JS_ONLOADERROR, new String[] {
                    (new StringBuilder("Init: ")).append(e.getMessage()).toString()});
                e.printStackTrace();
            javascript(JS_ONLOAD, null);
        /** This method is called from within the init() method to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" C�digo Generado ">
        private void initComponents() {
            this.setSize(350, 450);
            appletPanel = new javax.swing.JPanel();
            jPanel1 = new javax.swing.JPanel();
            jTextField1 = new javax.swing.JLabel();
            jPanel2 = new javax.swing.JPanel();
            label = new javax.swing.JLabel();
            jPanel3 = new javax.swing.JPanel();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            setLayout(new java.awt.BorderLayout());
            appletPanel.setBackground(new java.awt.Color(255, 255, 255));
            appletPanel.setMaximumSize(new java.awt.Dimension(350, 430));
            appletPanel.setMinimumSize(new java.awt.Dimension(350, 430));
            appletPanel.setPreferredSize(new java.awt.Dimension(350, 430));
            jPanel1.setBackground(new java.awt.Color(255, 255, 255));
            jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 204)));
            jTextField1.setFont(new java.awt.Font("Arial", 1, 18));
            jTextField1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jTextField1.setText("SIGNATURA ELECTRONICA");
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
                    .addContainerGap())
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
                    .addContainerGap())
            jPanel2.setBackground(new java.awt.Color(255, 255, 255));
            jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 204)));
            label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            label.setIcon(new javax.swing.ImageIcon("C:\\java\\workspaces\\cambrabcn\\firmasElectronicas\\logo.gif"));
            org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
            jPanel2.setLayout(jPanel2Layout);
            jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
                    .addContainerGap())
            jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(label)
                    .addContainerGap(229, Short.MAX_VALUE))
            jPanel3.setBackground(new java.awt.Color(255, 255, 255));
            jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 204)));
            //this.jButton1.setVisible(false);
            //this.jButton2.setVisible(false);
            jButton1.setText("Seg\u00fcent");
            jButton1.setAlignmentX(0.5F);
            //Cargamos el primer formulario en el JPanel2
            loadFirstForm();
            //Modificamos el texto del bot�n y el contador de pasos.
            //this.jButton1.setText("Siguiente");
            //this.jButton1.setVisible(true);
            //this.jButton2.setVisible(true);
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jButton2.setText("Cancel\u00b7lar");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 112, Short.MAX_VALUE)
                    .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton2)
                        .add(jButton1))
                    .addContainerGap())
            org.jdesktop.layout.GroupLayout appletPanelLayout = new org.jdesktop.layout.GroupLayout(appletPanel);
            appletPanel.setLayout(appletPanelLayout);
            appletPanelLayout.setHorizontalGroup(
                appletPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, appletPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(appletPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap())
            appletPanelLayout.setVerticalGroup(
                appletPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(org.jdesktop.layout.GroupLayout.TRAILING, appletPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            add(appletPanel, java.awt.BorderLayout.CENTER);
        }// </editor-fold>
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            this.destroy();
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            changeForms(this.paso);
        // Declaraci�n de variables - no modificar
        private javax.swing.JPanel appletPanel;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JPanel jPanel2;
        private javax.swing.JPanel jPanel3;
        private javax.swing.JLabel jTextField1;
        private javax.swing.JLabel label;
        // Fin de declaraci�n de variables
         * M�todo readParameters
         * M�todo que inicializa los valores de los par�metros internos, recibidos por par�metro.
        private void readParameters() throws FileNotFoundException, IOException {
             ???????????????? deleted for the forum
            addSecurityProviders();
         * M�tode loadFirstForm
         * Aquest m�tode carrega a jPanel2 el formulari que informa sobre la c�rrega dels arxius
        private void loadFirstForm(){
            //Form1 f1 = new Form1(stream, i + 1, fileURL.size(), sender.returnCurrentContentLength(), appletBackground);
            //Form1 f1 = new Form1(fileURL.size(), sender.returnCurrentContentLength());
            Form1 f1 = new Form1();
            //Lo dimensionamos y posicionamos
            f1.setSize(310, 150);
            f1.setLocation(10, 110);
            //A�adimos el formulario al JPanel que lo contendr�
            this.jPanel2.add(f1);
            //Validem i repintem el JPanel
            jPanel2.validate();
            jPanel2.repaint();
            //Descarreguem l'arxiu a signar
            *System.out.println("FormularioApplet Dentro de loadFirstForm(), antes de llamar a getDownloadFile()");*
            *byte obj[] = f1.getDownloadedFile(this.documentToSign);*
            if (obj == null){
                System.out.println("Lo que devuelve f1.getDownloadedFile(this.documentToSign) es NULL");
            else{
                System.out.println("Lo que devuelve f1.getDownloadedFile(this.documentToSign) NO es NULL");
                System.out.println("obj: " + obj.length);
            this.ftbsigned.add(obj);
            System.out.println("FormularioApplet Dentro de loadFirstForm(), despu�s de llamar a getDownloadFile()");
            //Indicamos que el primer paso ya se ha efectuado
            this.paso++;
         * M�tode changeForms
         * Aquest m�tode carrega a jPanel2 un formulari concret segons el valor de la variable global "paso"
        private void changeForms(int paso){
            /*A cada paso se cargar� en el JPanel y formulario diferente
             * Paso previo: Se realiza en la inicializaci�n, carga el formulario, descarga el archivo y muestra la barra de carga.
             * Case 1: Se carga el formulario de selecci�n de tipo de firma.
             * Case 2: Se carga el formulario de datos de la persona que firma.
            this.paso = paso;
            switch(paso){
                case 1:
                    //Creamos un objeto de formulario (seleccion de tipo de firma)
                    Form2 f2 = new Form2();
                    //Lo dimensionamos y posicionamos
                    f2.setSize(310, 185);
                    f2.setLocation(10, 110);
                    //Quitamos el formulario 1 y a�adimos el formulario 2 al JPanel
                    this.jPanel2.remove(1);
                    this.jPanel2.add(f2);
                    //Validem i repintem el JPanel
                    jPanel2.validate();
                    jPanel2.repaint();
                    //Modificamos el contador de pasos.
                    this.paso++;
                    break;
                case 2:
                    //Creamos un objeto de formulario (seleccion de tipo de firma)
                    Form3 f3 = new Form3();
                    //Lo dimensionamos y posicionamos
                    f3.setSize(310, 175);
                    f3.setLocation(15, 130);
                    //Quitamos el formulario 1 y a�adimos el formulario 3 al JPanel
                    this.jPanel2.remove(1);
                    this.jPanel2.add(f3);
                    //Validem i repintem el JPanel
                    jPanel2.validate();
                    jPanel2.repaint();
                    //Modificamos el texto del bot�n y el contador de pasos.
                    this.jButton1.setText("Finalizar");
                    this.paso++;
                    break;
                default:
                    //Finalizar el Applet
                    //C�digo que se encargue de guardar el archivo en el disco duro del usuario
                    break;
        private void addSecurityProviders() throws FileNotFoundException, IOException {
            Security.addProvider(new CryptoAPIProvider());
            if (signatureType == SIGNATURE_PDF) {
                Security.addProvider(new BouncyCastleProvider());
            else {
                Security.addProvider(new Sun());
        private File createOutputFile(String filename, int index) {
            return new File((String)outputFilename.get(index));
        protected Object javascript(String function, String args[]) throws RuntimeException {
            //Remove
            if (true) return null;
            try {
                Vector<String> list = new Vector<String>();
                if(args != null) {
                    for(int i = 0; i < args.length; i++) {
                        list.addElement(args);
    if(list.size() > 0) {
    Object objs[] = new Object[list.size()];
    list.copyInto(objs);
    return JSObject.getWindow(this).call(function, objs);
    } catch(UnsatisfiedLinkError e) {
    e.printStackTrace();
    throw new RuntimeException((new StringBuilder()).append(e).append("\nFunci�: ").append(function).toString());
    } catch(Throwable e) {
    e.printStackTrace();
    throw new RuntimeException((new StringBuilder()).append(e).append("\nFunci�: ").append(function).toString());
    return JSObject.getWindow(this).call(function, new Object[0]);
    Edited by: Kefalegereta on Oct 31, 2007 3:54 AM
    Edited by: Kefalegereta on Oct 31, 2007 4:00 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    Additional things to try.
    Try this first. Turn Off your iPad. Then turn Off (disconnect power cord) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    Change the channel on your wireless router. Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    Another thing to try - Go into your router security settings and change from WEP to WPA with AES.
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    If none of the above suggestions work, look at this link.
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • NT security problems with file I/O

    I have 2 problems with file I/O. When I read from a file I use the getAbsolutePath() method that is part of the File class to find what directory the files are currenlty. The problem is that the returned path says that the file is on the desktop no matter what directory the file really is in. The second problem is that I am unable to save files anywhere but the desktop. I must run the class files from the desktop too to get it to work.
    I am using NT 4.0 for development. I'm guessing that these problems might be NT security related. Could someone help me?
    Code below:
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.io.File;
    import java.awt.event.*;
    //import java.security.*;
    //import sun.security.*;
    //import java.awt.Window;
    //import com.ms.security.*;
    public class Edit extends Applet implements ActionListener, ItemListener
    String Gselect;
    reader readit;
    int mhz, khz;
    TextField textField1;
    String freq = "000.000";
    String data;
    Choice freqC;
    Button ActivateB, SaveB, /*CancelB, HelpB,*/ DeleteB;
    Checkbox SetC;
    int NotUsedReply[] = new int[200];
    int HwListReply[] = new int[200];
    public void init()
    readit = new reader();
    String myFile="satellite.st1";
    // myFile = myFile.concat(Gselect);
    File satellite = new File(myFile);
    textField1 = new TextField();
    textField1.setText( "(void) " );
    add( textField1 );
    SetC = new Checkbox("TRAP-RX");
    add(SetC);
    SetC.addItemListener(this);
    freqC = new Choice();
    freqC.setSize(20,50);
    freqC.add("000.000");
    add(freqC);
    freqC.addItemListener(this);
    ActivateB = new Button("Activate");
    add(ActivateB);
    ActivateB.addActionListener(this);
    SaveB = new Button("Save");
    add(SaveB);
    SaveB.addActionListener(this);
    DeleteB = new Button("Delete");
    add(DeleteB);
    DeleteB.addActionListener(this);
         /*CancelB = new Button("Cancel");
    add(CancelB);
    CancelB.addActionListener(this);
         HelpB = new Button("Help");
    add(HelpB);
    HelpB.addActionListener(this);*/
    //textField1.setText( data );
    for(int a = 1; a < 9; a++)
    data = readit.getData(satellite.getAbsolutePath(), a);//("E:\\forte4j\\system\\Projects\\Zebra\\satellite.st1", a);
    freqC.addItem(data);
    textField1.setText(satellite.getAbsolutePath() );
    public void paint(Graphics g)
    //g.drawString("Radio Setup Files",20, 20);
    //g.drawString(getParameter("wse"),20, 20);
    public void actionPerformed(ActionEvent event)
    if(event.getSource() == ActivateB)
    activator();
    if(event.getSource() == SaveB)
    /*if(event.getSource() == CancelB)
    stop();
    if(event.getSource() == HelpB)
    if(event.getSource() == DeleteB)
    public void itemStateChanged(ItemEvent e)
    if(e.getItemSelectable() == SetC)
    textField1.setText("Check box 1 clicked!");
    if(e.getItemSelectable() == freqC)
    freq = ((Choice)e.getItemSelectable()).getSelectedItem();
    public void activator()
    makeMHZ();
    makeKHZ();
    if(mhz > 254)
    int StartLink[]={0x0c,0x01,0x07,0x00,0x00,0x00,0x00,0x00,0x00};          //New Link Proc Start
    int TrapConfig[]={0x25,0x80,0x00,0x00,0x00,0xb7,0x00,0x0c,0x0b,          //TRAP Configuration
    0x00,0x00,0x00,0xff,0xa0,0xff,0x0d,0xff,0xe8,
    0xff,0x0d,0xff,0x00,0xff,0x15,0xff,0xb0,0xff,
    0xff,0xff,0x94,0x0a,0x01,0x06,0x1a,0x00,0x0d,
    0x2d,0x21};
    TrapConfig[11]=(mhz-255);
    TrapConfig[12]=(khz/5);
    int SetUserOutput[]={0x41,0x42,0x49,0x54,0x52,0x41,0x50,0x20,0x34, //Sets User Output Format
    0x35,0x34,0x35,0x30,0x30,0x2e,0x30,0x4e,0x30,
    0x38,0x32,0x34,0x35,0x30,0x30,0x2e,0x30,0x57,
    0x30,0x31,0x30,0x30,0x2e,0x30,0x30,0x4b,0x4d,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00};
    sendget CmdFunc;
    CmdFunc=new sendget();
    try
    //PolicyEngine.assertPermission(PermissionID.SYSTEM);
    Socket h = new Socket("192.9.200.155",9000);
    Socket s = new Socket("192.9.200.155",9001);
    Socket t = new Socket("192.9.200.155",9002);
    int j;
    CmdFunc.SendCmd(h,0,0x01,null);
    CmdFunc.GetCmd(h,HwListReply);
    CmdFunc.SendCmd(s,9,0x1e,StartLink); //New Link Proc Start
    CmdFunc.GetCmd(s,NotUsedReply);
    CmdFunc.SendCmd(s,37,0x00,TrapConfig); //TRAP Configuration
    CmdFunc.GetCmd(s,NotUsedReply);
    CmdFunc.SendCmd(s,155,0x03,SetUserOutput);//Sets User Output Format
    CmdFunc.GetCmd(s,NotUsedReply);
    catch(Exception e){}
    else
    textField1.setText( "000.000 is the null choice. Try another." );
    public void receiveText1( String select )
    Gselect=select;
    public void makeMHZ()
    String y = freqC.getSelectedItem();
    y = y.substring(0,3);
    mhz = Integer.parseInt(y);
    //textField1.setText( y );
    public void makeKHZ()
    String y = freqC.getSelectedItem();
    y = y.substring(4,7);
    khz = Integer.parseInt(y);
    //textField1.setText( y );
    import java.awt.*;
    import java.applet.*;
    import java.io.RandomAccessFile;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.LineNumberReader;
    import java.awt.event.*;
    import com.ms.security.*;
    import netscape.security.*;
    import netscape.util.*;
    public class saver extends Applet implements ActionListener
    String nameS = "Data.txt";
    String dataS = "Default Data";
    Button saveB;
    public void init()
    saveB = new Button("SaveFile");
    add(saveB);
    saveB.addActionListener(this);
    public void actionPerformed(ActionEvent event)
    if(event.getSource() == saveB)
    RandomAccessFile RAF;
    byte array0[] = dataS.getBytes();
    try
    if (Class.forName("com.ms.security.PolicyEngine") != null)
    PolicyEngine.assertPermission(PermissionID.SYSTEM);
    if(Class.forName("netscape.security.PrivilegeManager") != null)
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileWrite");
    catch (Throwable cnfe)
    try
    RAF = new RandomAccessFile(nameS, "rw");
    // RAF.writeUTF(dataS);
    RAF.write(dataS.getBytes());
    RAF.close();
    catch(Exception e)
    public void receiveND(String name, String data)
    if(name != null)
    nameS = name;
    dataS=data;
    import java.io.RandomAccessFile;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.LineNumberReader;
    //import java.security.*;
    import com.ms.security.*;
    import netscape.security.*;
    import netscape.util.*;
    public class reader
    //Signature sig;
    public String getData(String filename, int pass)
    //String nameS = "Data.txt";
    String dataS = "Default Data Sucks";
    String comma = ",";
    int get = pass, count=0, top=0, bottom=0;
    char[] work;
    try
    if (Class.forName("com.ms.security.PolicyEngine") != null)
    PolicyEngine.assertPermission(PermissionID.SYSTEM);
    if(Class.forName("netscape.security.PrivilegeManager") != null)
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
    catch (Throwable cnfe)
    try
    //sig.sign();
    //nameS = filename;
    RandomAccessFile RAF = new RandomAccessFile(filename, "r");
    // dataS = RAF.readUTF();
    dataS = RAF.readLine();
    RAF.close();
    catch(Exception e)
    return e.toString();
    work = dataS.toCharArray();
    for(int i = 0; i < dataS.length(); i++)
    if( work[i] == ',' )
    count++;
    if(get == count)
    bottom = i + 1;
    if( (work[i] == ',') && (count > get) && (top == 0) )
    top = i;
    dataS = dataS.substring(bottom,top);
    return dataS;
    }

    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.io.File;
    import java.awt.event.*;
    //import java.security.*;
    //import sun.security.*;
    //import java.awt.Window;
    //import com.ms.security.*;
    public class Edit extends Applet implements ActionListener, ItemListener
    String Gselect;
    reader readit;
    int mhz, khz;
    TextField textField1;
    String freq = "000.000";
    String data;
    Choice freqC;
    Button ActivateB, SaveB, /*CancelB, HelpB,*/ DeleteB;
    Checkbox SetC;
    int NotUsedReply[] = new int[200];
    int HwListReply[] = new int[200];
    public void init()
    readit = new reader();
    String myFile="satellite.st1";
    // myFile = myFile.concat(Gselect);
    File satellite = new File(myFile);
    textField1 = new TextField();
    textField1.setText( "(void) " );
    add( textField1 );
    SetC = new Checkbox("TRAP-RX");
    add(SetC);
    SetC.addItemListener(this);
    freqC = new Choice();
    freqC.setSize(20,50);
    freqC.add("000.000");
    add(freqC);
    freqC.addItemListener(this);
    ActivateB = new Button("Activate");
    add(ActivateB);
    ActivateB.addActionListener(this);
    SaveB = new Button("Save");
    add(SaveB);
    SaveB.addActionListener(this);
    DeleteB = new Button("Delete");
    add(DeleteB);
    DeleteB.addActionListener(this);
    /*CancelB = new Button("Cancel");
    add(CancelB);
    CancelB.addActionListener(this);
    HelpB = new Button("Help");
    add(HelpB);
    HelpB.addActionListener(this);*/
    //textField1.setText( data );
    for(int a = 1; a < 9; a++)
    data = readit.getData(satellite.getAbsolutePath(), a);//("E:\\forte4j\\system\\Projects\\Zebra\\satellite.st1", a);
    freqC.addItem(data);
    textField1.setText(satellite.getAbsolutePath() );
    public void paint(Graphics g)
    //g.drawString("Radio Setup Files",20, 20);
    //g.drawString(getParameter("wse"),20, 20);
    public void actionPerformed(ActionEvent event)
    if(event.getSource() == ActivateB)
    activator();
    if(event.getSource() == SaveB)
    /*if(event.getSource() == CancelB)
    stop();
    if(event.getSource() == HelpB)
    if(event.getSource() == DeleteB)
    public void itemStateChanged(ItemEvent e)
    if(e.getItemSelectable() == SetC)
    textField1.setText("Check box 1 clicked!");
    if(e.getItemSelectable() == freqC)
    freq = ((Choice)e.getItemSelectable()).getSelectedItem();
    public void activator()
    makeMHZ();
    makeKHZ();
    if(mhz > 254)
    int StartLink[]={0x0c,0x01,0x07,0x00,0x00,0x00,0x00,0x00,0x00}; //New Link Proc Start
    int TrapConfig[]={0x25,0x80,0x00,0x00,0x00,0xb7,0x00,0x0c,0x0b, //TRAP Configuration
    0x00,0x00,0x00,0xff,0xa0,0xff,0x0d,0xff,0xe8,
    0xff,0x0d,0xff,0x00,0xff,0x15,0xff,0xb0,0xff,
    0xff,0xff,0x94,0x0a,0x01,0x06,0x1a,0x00,0x0d,
    0x2d,0x21};
    TrapConfig[11]=(mhz-255);
    TrapConfig[12]=(khz/5);
    int SetUserOutput[]={0x41,0x42,0x49,0x54,0x52,0x41,0x50,0x20,0x34, //Sets User Output Format
    0x35,0x34,0x35,0x30,0x30,0x2e,0x30,0x4e,0x30,
    0x38,0x32,0x34,0x35,0x30,0x30,0x2e,0x30,0x57,
    0x30,0x31,0x30,0x30,0x2e,0x30,0x30,0x4b,0x4d,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00};
    sendget CmdFunc;
    CmdFunc=new sendget();
    try
    //PolicyEngine.assertPermission(PermissionID.SYSTEM);
    Socket h = new Socket("192.9.200.155",9000);
    Socket s = new Socket("192.9.200.155",9001);
    Socket t = new Socket("192.9.200.155",9002);
    int j;
    CmdFunc.SendCmd(h,0,0x01,null);
    CmdFunc.GetCmd(h,HwListReply);
    CmdFunc.SendCmd(s,9,0x1e,StartLink); //New Link Proc Start
    CmdFunc.GetCmd(s,NotUsedReply);
    CmdFunc.SendCmd(s,37,0x00,TrapConfig); //TRAP Configuration
    CmdFunc.GetCmd(s,NotUsedReply);
    CmdFunc.SendCmd(s,155,0x03,SetUserOutput);//Sets User Output Format
    CmdFunc.GetCmd(s,NotUsedReply);
    catch(Exception e){}
    else
    textField1.setText( "000.000 is the null choice. Try another." );
    public void receiveText1( String select )
    Gselect=select;
    public void makeMHZ()
    String y = freqC.getSelectedItem();
    y = y.substring(0,3);
    mhz = Integer.parseInt(y);
    //textField1.setText( y );
    public void makeKHZ()
    String y = freqC.getSelectedItem();
    y = y.substring(4,7);
    khz = Integer.parseInt(y);
    //textField1.setText( y );
    import java.awt.*;
    import java.applet.*;
    import java.io.RandomAccessFile;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.LineNumberReader;
    import java.awt.event.*;
    import com.ms.security.*;
    import netscape.security.*;
    import netscape.util.*;
    public class saver extends Applet implements ActionListener
    String nameS = "Data.txt";
    String dataS = "Default Data";
    Button saveB;
    public void init()
    saveB = new Button("SaveFile");
    add(saveB);
    saveB.addActionListener(this);
    public void actionPerformed(ActionEvent event)
    if(event.getSource() == saveB)
    RandomAccessFile RAF;
    byte array0[] = dataS.getBytes();
    try
    if (Class.forName("com.ms.security.PolicyEngine") != null)
    PolicyEngine.assertPermission(PermissionID.SYSTEM);
    if(Class.forName("netscape.security.PrivilegeManager") != null)
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileWrite");
    catch (Throwable cnfe)
    try
    RAF = new RandomAccessFile(nameS, "rw");
    // RAF.writeUTF(dataS);
    RAF.write(dataS.getBytes());
    RAF.close();
    catch(Exception e)
    public void receiveND(String name, String data)
    if(name != null)
    nameS = name;
    dataS=data;
    import java.io.RandomAccessFile;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.LineNumberReader;
    //import java.security.*;
    import com.ms.security.*;
    import netscape.security.*;
    import netscape.util.*;
    public class reader
    //Signature sig;
    public String getData(String filename, int pass)
    //String nameS = "Data.txt";
    String dataS = "Default Data Sucks";
    String comma = ",";
    int get = pass, count=0, top=0, bottom=0;
    char[] work;
    try
    if (Class.forName("com.ms.security.PolicyEngine") != null)
    PolicyEngine.assertPermission(PermissionID.SYSTEM);
    if(Class.forName("netscape.security.PrivilegeManager") != null)
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
    catch (Throwable cnfe)
    try
    //sig.sign();
    //nameS = filename;
    RandomAccessFile RAF = new RandomAccessFile(filename, "r");
    // dataS = RAF.readUTF();
    dataS = RAF.readLine();
    RAF.close();
    catch(Exception e)
    return e.toString();
    work = dataS.toCharArray();
    for(int i = 0; i < dataS.length(); i++)
    if( work == ',' )
    count++;
    if(get == count)
    bottom = i + 1;
    if( (work == ',') && (count > get) && (top == 0) )
    top = i;
    dataS = dataS.substring(bottom,top);
    return dataS;

  • Problem with file writing

    Hello, I have a problem with writing a file. My code is very simple..it takes a line from one file, a line from a second file, combines them, and writes them into the third file. However, the program never gets past the point where it creates the output file. Any help is appreciated.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MergeFiles extends JApplet implements ActionListener
        private final String filename = "mergedfiles.txt";
        BufferedReader f1in, f2in;
        FileOutputStream outputstream;
        JTextField f1f = new JTextField("file1.txt", 20);
        JTextField f2f = new JTextField("file2.txt", 20);
        String F1text, F2text, F3text;
        JLabel title = new JLabel("Merge files program! Press enter to merge!");
        JButton merge = new JButton("MERGE! MERGE! MERGE!");
        JLabel labelone = new JLabel("File one");
        JLabel labeltwo = new JLabel("File two");
        Container con = getContentPane();
        JPanel pane = new JPanel();
        GridBagConstraints c = new GridBagConstraints();
        public void makedisplay()
            Insets i = new Insets(10, 10, 10, 10);
            pane.setLayout(new GridBagLayout());
            pane.setBackground(Color.green);
            con.setBackground(Color.green);
            con.add(pane, BorderLayout.CENTER);
            con.add(title, BorderLayout.NORTH);
            c.weightx = 0;
            c.insets = i;
            c.gridy = 0;
            c.gridx = 0;
            pane.add(labelone, c);
            c.gridx = 1;
            pane.add(labeltwo, c);
            c.gridx = 0;
            c.gridy = 1;
            c.ipadx = 50;
            pane.add(f1f, c);
            c.gridx = 1;
            pane.add(f2f, c);
            c.gridx = 0;
            c.gridy = 2;
            c.gridwidth = 3;
            c.ipadx = 0;
            pane.add(merge, c);
        public void init()
            makedisplay();
            merge.addActionListener(this);
        public void actionPerformed(ActionEvent e)
            openfiles();
            File f = new File("H://mergefiles//mergedfile.txt");
            try {
                title.setText("AAA");
                BufferedWriter out = new BufferedWriter(new FileWriter(f));
                F1text = f1in.readLine();
                F2text = f2in.readLine();
                title.setText("BBB");
                F3text = "" + F1text + F2text;
                out.write("" + F3text);
                f1in.close();
                f2in.close();
                out.close();
             catch (IOException ex)
        public void openfiles()
            try
                BufferedReader f1in = new BufferedReader(new FileReader(f1f.getText()));
                title.setText("file one opened");
            catch (FileNotFoundException e)
                title.setText("File one not found!");
            try
                BufferedReader f2in = new BufferedReader(new FileReader(f2f.getText()));
                title.setText("File two opened");
            catch (FileNotFoundException e)
                title.setText("File two not found!");
    }

    Nevermind, I've fixed the problem...for some reason you can't use the writer with an applet. I've written some new code that works:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MergeFiles2
        static String F1L = "", F2L = "";
        static File file1 = new File("H://mergefiles//file1.txt");
        static File file2 = new File("H://mergefiles//file2.txt");
        public static void main(String[] args) throws IOException
            PrintWriter out = new PrintWriter(new FileWriter("file3.txt"));
            BufferedReader f1in = new BufferedReader(new FileReader(file1));
            BufferedReader f2in = new BufferedReader(new FileReader(file2));
            while (F1L != null)
                F1L = f1in.readLine();
                if (F1L != null)
                    out.println(F1L);
            while (F2L != null)
                F2L = f2in.readLine();
                if (F2L != null)
                    out.println(F2L);
            out.close();
    }

  • Problem with placing of properties file

    Hi all,
    Iam using a properties file.
    From a jsp, Iam reading the property file.....
    Its giving FileNotFoundException....
    I hope its problem with placing of my properties file...
    I placed the properties file in WEB-INF/classes..folder.....
    But still iam getting the FileNotFoundException...
    PLz tell me where exactly should I place my properties file...
    Thanks ....

    first rule of using a forum: read recent topics !
    http://forum.java.sun.com/thread.jspa?threadID=668488&tstart=0

  • Problem with printing txt file

    I have a problem with printing txt file. My code looks like :
    String filename = something.txt";
    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
    PrintService[] services = PrintServiceLookup.lookupPrintServices(
              flavor, null);
    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    pras.add(PrintQuality.DRAFT);
    pras.add(new Copies(1));
    pras.add(MediaSizeName.ISO_A4);
    pras.add(Sides.ONE_SIDED);
    pras.add(Chromaticity.MONOCHROME);
    PrintService service = ServiceUI.printDialog(null, 200, 200,
              services, services[0],
              null,
              pras);
    if (service != null)
    try
    DocPrintJob job = service.createPrintJob();
    FileInputStream fis = new FileInputStream(filename);
    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(fis, flavor, das);
    job.print(doc, pras);
    Thread.sleep(10000);
    catch(FileNotFoundException e)
    catch(PrintException e1)
    catch(InterruptedException e2)
    It doesn't work :(
    What is my purpose: I would like to print .txt file but I would like to get PrintDialog where I can choose PrintQuality, Chromaticity etc. I found also that I should use DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST but I don't know how.
    I will be very gratefull for help :)

    I tested it on 3 printers (different models of hp). 2 of them don't give me any error but when it started print priter stoped (just as it dosesn't have a paper), but 1 of them doesn't react (there were no errors), i thought tahat something was wrong with printers but when I change DocFlavor.INPUT_STREAM.AUTOSENSE to DocFlavor.GIF and filename to dog.gif it works so mybe there is another way to print txt file

  • Problem with Database Control

    Hi @all
    OS Windows Server 2008 (Standard)
    DB 11.1.0.7.0
    I try to configure DB Control manually with
    D:\ORACLE\product\11.1.0\db_1\BIN>emca -config dbcontrol db -repos create
    result is
    15.09.2009 13:19:14 oracle.sysman.emcp.EMConfig perform
    INFO: Dieser Vorgang wird in D:\ORACLE\cfgtoollogs\emca\SAXMBS\emca_2009_09_15_1
    3_15_52.log protokolliert.
    15.09.2009 13:19:15 oracle.sysman.emcp.util.FileUtil backupFile
    WARNUNG: Datei D:\ORACLE\product\11.1.0\db_1\sysman\config\emd.properties konnte
    nicht gesichert werden
    15.09.2009 13:19:15 oracle.sysman.emcp.util.FileUtil backupFile
    WARNUNG: Datei D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties.emca
    konnte nicht gesichert werden
    15.09.2009 13:19:15 oracle.sysman.emcp.util.FileUtil backupFile
    WARNUNG: Datei D:\ORACLE\product\11.1.0\db_1\sysman\emd\targets.xml konnte nicht
    gesichert werden
    15.09.2009 13:19:15 oracle.sysman.emcp.util.DBControlUtil stopOMS
    INFO: Database Control wird gestoppt (dies kann etwas lõnger dauern) ...
    15.09.2009 13:19:15 oracle.sysman.emcp.EMReposConfig createRepository
    INFO: Das EM-Repository wird erstellt (dies kann etwas lõnger dauern)...
    15.09.2009 13:24:22 oracle.sysman.emcp.EMReposConfig invoke
    INFO: Repository erfolgreich erstellt
    15.09.2009 13:24:23 oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepositor
    y
    INFO: Konfigurationsdaten werden in das EM-Repository hochgeladen (dies kann etw
    as lõnger dauern) ...
    15.09.2009 13:25:02 oracle.sysman.emcp.EMReposConfig invoke
    INFO: Konfigurationsdaten wurden erfolgreich hochgeladen
    15.09.2009 13:25:02 oracle.sysman.emcp.EMConfig perform
    SCHWERWIEGEND: Fehler beim Aktualisieren von D:\ORACLE\product\11.1.0\db_1\sysma
    n\config\emoms.properties
    Weitere Einzelheiten finden Sie in der Log-Datei in D:\ORACLE\cfgtoollogs\emca\S
    AXMBS\emca_2009_09_15_13_15_52.log.
    Die Konfiguration konnte nicht abgeschlossen werden. Weitere Einzelheiten finden
    Sie in der Log-Datei in D:\ORACLE\cfgtoollogs\emca\SAXMBS\emca_2009_09_15_13_15
    _52.log.
    snippet of the log
    at oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:468)
    Caused by: java.io.FileNotFoundException: D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties (Zugriff verweigert)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
         at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
         at oracle.sysman.emcp.util.FileUtil._copyFile(FileUtil.java:257)
         ... 11 more
    15.09.2009 13:25:02 oracle.sysman.emcp.EMDBCConfig updateEmomsProps
    KONFIG: Datei D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties.emca wird in D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties kopiert
    15.09.2009 13:25:02 oracle.sysman.emcp.EMConfig perform
    SCHWERWIEGEND: Fehler beim Aktualisieren von D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties
    Weitere Einzelheiten finden Sie in der Log-Datei in D:\ORACLE\cfgtoollogs\emca\SAXMBS\emca_2009_09_15_13_15_52.log.
    15.09.2009 13:25:02 oracle.sysman.emcp.EMConfig perform
    KONFIG: Stack Trace:
    oracle.sysman.emcp.exception.EMConfigException: Fehler beim Aktualisieren von D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties
         at oracle.sysman.emcp.EMDBCConfig.performConfiguration(EMDBCConfig.java:405)
         at oracle.sysman.emcp.EMDBCConfig.invoke(EMDBCConfig.java:167)
         at oracle.sysman.emcp.EMDBCConfig.invoke(EMDBCConfig.java:137)
         at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:223)
         at oracle.sysman.emcp.EMConfigAssistant.invokeEMCA(EMConfigAssistant.java:535)
         at oracle.sysman.emcp.EMConfigAssistant.performConfiguration(EMConfigAssistant.java:1215)
         at oracle.sysman.emcp.EMConfigAssistant.statusMain(EMConfigAssistant.java:519)
         at oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:468)
    the problem is Caused by: java.io.FileNotFoundException: D:\ORACLE\product\11.1.0\db_1\sysman\config\emoms.properties (access denied)
    and when i try to deconfig this following occured
    15.09.2009 13:30:28 oracle.sysman.emcp.EMConfig perform
    INFO: Dieser Vorgang wird in D:\ORACLE\cfgtoollogs\emca\SAXMBS\emca_2009_09_15_1
    3_29_13.log protokolliert.
    15.09.2009 13:30:28 oracle.sysman.emcp.util.DBControlUtil stopOMS
    INFO: Database Control wird gestoppt (dies kann etwas lõnger dauern) ...
    15.09.2009 13:30:28 oracle.sysman.emcp.EMConfig perform
    SCHWERWIEGEND: Can't find file D:\ORACLE\product\11.1.0\db_1\host\sysman\config\emoms.properties
    Weitere Einzelheiten finden Sie in der Log-Datei in D:\ORACLE\cfgtoollogs\emca\S
    AXMBS\emca_2009_09_15_13_29_13.log.
    Die Konfiguration konnte nicht abgeschlossen werden. Weitere Einzelheiten finden
    Sie in der Log-Datei in D:\ORACLE\cfgtoollogs\emca\SAXMBS\emca_2009_09_15_13_29
    _13.log.
    Can't find file D:\ORACLE\product\11.1.0\db_1\host_db\sysman\config\emoms.properties
    With Windows Server 2003 I haven't any problems with the configuration of database control over cmd.
    Any Ideas?

    Please run the following command
    cmd>net start OracleDBConsolexxx(Assume sid name=xxx
    cmd>set oracle_sid=xxx
    cmd>emca (You will get all related keyword of emca)
    Firstly you have to check that if you have created your database through DBCA then you have to drop old repository or recreate repository:
    To drop (remove) the configuration files and repository for Database Console, run:
    cmd>emca -deconfig dbcontrol db -repos drop
    To recreate (remove & create) the configuration files and repository for Database Console, run:
    cmd>emca -config dbcontrol db -repos recreate
    (Please mark it helpful/Answered if you get solution)
    Regards,
    Suman

  • Urgent!!!! please help!!! problems with visual j++ and jbuilder

    Hi,
    I have been worried about this problem since a long time. I couldn't get any help figuring out the problem. I am using microsoft visual j++ 6.0
    I have tried putting the rt.jar file in the class path but its getting me out of the compilation errors and not this runtime error.
    I faced this problem with many codes.
    When i used the jbuilder as one of the users suggested, i am getting this compilation errors,
    "FloatingAgent.java": Error #: 704 : cannot access directory vrml at line 4, column 4
    "FloatingAgent.java": Error #: 704 : cannot access directory vrml\node at line 5, column 4
    "FloatingAgent.java": Error #: 704 : cannot access directory vrml\field at line 6, column 4
    "FloatingAgent.java": Error #: 300 : class Script not found in class FloatingAgent at line 9, column 39
    Please somebody help.
    Jagadish.
    // an agent is floating randomly.
    import java.util.*;
    import vrml.*;
    import vrml.node.*;
    import vrml.field.*;
    import java.io.*;
    public class FloatingAgent extends Script{
    SFVec3f setAgentPosition;
    SFRotation setAgentRosition;
         static int count=0;
         float agentPosition[] = new float[3];
         float agentRosition[] = new float[4];
         float rotangle = 0.0f;
         float aRad= (float) (Math.PI/180);
    //Random randomNumGenerator = new Random();
    public void initialize(){
    // get the reference of the event-out 'setAgentPosition'.
    setAgentPosition =
    (SFVec3f)getEventOut("setAgentPosition");
              setAgentRosition =
    (SFRotation)getEventOut("setAgentRosition");
    // initialize the agent position.
    agentPosition[0] = 0.0f;
    agentPosition[1] = 0.0f;
    agentPosition[2] = 0.0f;
         agentRosition[0] = 0.0f;
    agentRosition[1] = 0.0f;
    agentRosition[2] = 1.0f;
         agentRosition[3] = 0.0f;
    public void processEvent(Event e){
    if(e.getName().equals("interval") == true){
    moveAgent();
    // generate random float value ranging between -0.1 to 0.1.
    /*float generateRandomFloat(){
    return(randomNumGenerator.nextFloat() * 0.2f - 0.1f);
    // move the agent randomly.
    void moveAgent()
    agentPosition = reader();
    // agentPosition[0] += generateRandomFloat() ;
    // agentPosition[1] += generateRandomFloat();
    //agentPosition[2] += generateRandomFloat();
         rotangle += 2.0f;
         agentRosition[3] = rotangle * aRad;
    // move the agent to the new position.
    setAgentPosition.setValue(agentPosition);
         setAgentRosition.setValue(agentRosition);
    }//move agent
    static float[] reader()
         float p1[] = new float[3];
         try{
         FileReader fr = new FileReader("data.txt");
         BufferedReader br = new BufferedReader(fr);
         String s;
    int count1=0;
    count++;     
         try{  
         while((s=br.readLine())!=null)
    count1++;
              StringTokenizer st = new StringTokenizer(s);
              if(count1==count)
              int i=0;
              while(st.hasMoreTokens())
              p1[i++]=Float.parseFloat(st.nextToken());
              }//if
              }//end of stringTokenizer while.
         fr.close();                
         catch(IOException f)
              System.out.println("file cannot be opened");
         }//try
         catch(FileNotFoundException e)
         System.out.println("file doesn't exist");
         } //try
         return p1;
    }//reader

    Didn't we hear this from you yesterday? Sounds too familiar. If so, we told you you're using a MICROSOFT product (Visual J++), which is OLD, and not up to the SUN's java specification. We suggested that you dump Visual J++ and go with something like JBuilder, Forte, Visual Cafe, etc.
    This is a SUN site in support of SUN's java - not Microsoft's outdated and non-existent (anymore) version.

  • Problems with matcher.find()

    Hi,
    Here is what I'm trying to do. Read one (or more later) files...one line at a time and compare it with a regular expresion to extract email addresses.
    Here is my code:
    public final class RegExpressions {
        private static String REGEX;
        private static String INPUT;
        private static BufferedReader br;
        private static Pattern pattern;
        private static Matcher matcher;
        private static boolean found, b;
    public static void main(String[] args) throws Exception {
            initResources();
    private static void initResources() {
           try {         
                      br = new BufferedReader(new FileReader("titleInfo.txt"));
           catch (FileNotFoundException fnfe) {
                System.out.println("Cannot locate input file! "+fnfe.getMessage());
                System.exit(0);
           try {           
                REGEX = "(((\\w)(.)*)+@)";
                INPUT = null ;
                INPUT = br.readLine();
                pattern = Pattern.compile(REGEX);
                while ((INPUT = br.readLine()) != null)
                     // Reset the matcher to begin its next match starting at
                     // the beginning of the newly-read line.
                     matcher.reset(INPUT);
                     matcher = pattern.matcher(INPUT);
                     // Search for a match. A Boolean true value returns if a
                     // match is found.
                     System.out.println("Current INPUT is: "+INPUT);
                     b = matcher.find();
                     System.out.println ("matcher.find() is: " +b);
                     if (matcher.find())
                          System.out.println (INPUT);
           } catch(IOException ioe){}
           catch(PatternSyntaxException pse) {
               System.out.println("There is a problem with the regular expression!");
               System.out.println("The pattern in question is: "+pse.getPattern());
               System.out.println("The description is: "+pse.getDescription());
               System.out.println("The message is: "+pse.getMessage());
               System.out.println("The index is: "+pse.getIndex());
               System.exit(0);
            System.out.println("Current REGEX is: "+REGEX);
            System.out.println("Current INPUT is: "+INPUT);
        }The file I read in looks like this:
    Integration of Scheduling and Replication in Data Grids
    Anirban Chakrti Depak R.A. Shuhis Supta
    Software Engineering and Technology Laboratory
    Something Something Ltd.
    My City, Horse Road
    Bangalore 560 100, India
    Tel: 91 80 852 0261
    Fax: 91 80 852 0740
    {an_chakrti, depak_ra, shuhis_supta }@address.com
    Now what happens is that matcher.find() never finishes executing. Meaning my programs gets stuck at that particular line. I tested with Print statements before and after...etc. Can anyone help me with this problem? Thanks

    the only problem is that some of the emails do not contain the full names. For example if from the text below I extract the email addresses...
    Reckoning Legislative Compliances with Service Oriented Architecture
    � A Proposed Approach1
    Naveen N. Kulkarni K M Senthil Kumar Dr. Srinivas Padmanabhuni
    Software Engineering and Technology Labs, Infosys Technologies Ltd., Bangalore, India.
    {naveen_kulkarni,senthil_km,srinivas_p}@infosys.com
    ....and I'm also able to tokenize them (into naveen and kulkarni for example). How do I use this information to extract the names, which have me mentioned earlier on in the text. The format in which the names are written is not the same. ie it differs from paper to paper. Here is the idea I had....
    it seems that the first part of the email address always exists as it in the full name. If I used that in a regular expression...and went through the text file again trying to match that reg exp...that should work shouldn't it?
    here is my attempt...doesn't work though....any ideas...or an explanation why my code doesn't work?
        private static void extractNames() {
           try {         
                      br = new BufferedReader(new FileReader("titleInfo.txt"));
           catch (FileNotFoundException fnfe) {
                System.out.println("Cannot locate input file! "+fnfe.getMessage());
                System.exit(0);
           try {           
                for (int i=0; i<emails.length;i++){
                     int index = emails.indexOf("_");
              if (emails[i].indexOf("_") != -1){
                   StringBuffer firstName = new StringBuffer(temp.substring(0,index));
                   REGEX = "((.)[ ])*"+firstName+"((.)[ ])";
              pattern = Pattern.compile(REGEX); // I get a null pointer exception on this line...?
         while ((INPUT = br.readLine()) != null )
                   matcher = pattern.matcher(INPUT);
              System.out.println("Current INPUT is: "+INPUT);
              System.out.println ("Matche found? " +b);
              if (matcher.find()){
                   System.out.println (INPUT);
                   System.exit(0);
    } catch(IOException ioe){}
    catch(PatternSyntaxException pse) {
    System.out.println("There is a problem with the regular expression!");
    System.out.println("The pattern in question is: "+pse.getPattern());
    System.out.println("The description is: "+pse.getDescription());
    System.out.println("The message is: "+pse.getMessage());
    System.out.println("The index is: "+pse.getIndex());
    System.exit(0);
    System.out.println("Current REGEX is: "+REGEX);
    System.out.println("Current INPUT is: "+INPUT);
    Thanks!

  • Having problems with File IO, not sure what im doing or lack thereof.

    This is my code, basically I create a class which reads data from a .dat file which contains names and salarys, based on a question i found on a forum online, anyways I first created the .dat, now I need to create a class which takes the .dat file and writes it to a .txt file...he is my code I keep getting an EOFException which I have read in the docs is caused by an unexpected stop in reading of the data from file. Any assistance with regards to this problem would be much appriciated. Here is my code:
    import java.io.*;
    public class EmployeeRead implements Serializable{
         public static void main(String[] args){
         String inFile = null;
         String outFile = null;
         if (args.length<2) {
         System.out.println("You must specify two input files and one output file.");
         try {
         InputStreamReader reader = new InputStreamReader(System.in);
         BufferedReader console = new BufferedReader(reader);
         System.out.print("Please type the name of the .dat file: ");
         inFile = console.readLine();
         System.out.print("Please type the name for the .txt file (Output): ");
         outFile = console.readLine();
         catch(IOException e) {
              System.err.println("Problem with input: " + e);
         System.exit(1);
         else {
         inFile = args[0];
         outFile = args[1];
         try {
         //inFileReader = new ObjectInputStream(inFile);
         //inFileBuffered = new BufferedReader(inFileReader);
         //ObjectInputStream inFileReader = null;
         //BufferedReader inFileBuffered = null;
         //Input Streams:
              FileInputStream obj = new FileInputStream(inFile);
              ObjectInputStream in = new ObjectInputStream(obj);
              //output stream:
              FileWriter out = new FileWriter(outFile);
         String name = null;
         Double salary = 0.0;
         Employee temp = (Employee)in.readObject();
         Class nameClass = temp.getClass();
         temp = new Employee("SallyJones", 23456);
         while(temp != null){
              name = (String)temp.getName();
              salary = (Double)temp.getSalary();
              out.write(name + " - " + salary);
              temp = (Employee)in.readObject();
              catch(FileNotFoundException e){
              System.err.println("File not found: " + e.toString());
              catch(IOException e){
                   System.err.println("Error with file: " + e.toString());
                   e.printStackTrace();
              catch(IndexOutOfBoundsException e){
                   System.err.println("Index is out of Bounds: " + e.toString());
                   e.printStackTrace();
              catch(NullPointerException e){
                   System.err.println("Error with String(NullPointerException):" + e);
                   e.printStackTrace();
              catch(ClassNotFoundException e){
                   System.err.println("Error with Class: " + e);
                   e.printStackTrace();
    }

    Sorry, I was unaware of the code function. My Bad, here is the formatted code:
    import java.io.*;
    public class EmployeeRead implements Serializable{
         public static void main(String[] args){
             String inFile = null;
             String outFile = null;
              if (args.length<2) {
                  System.out.println("You must specify two input files and one output file.");
                  try {
                     InputStreamReader reader = new InputStreamReader(System.in);
                     BufferedReader console = new BufferedReader(reader);
                     System.out.print("Please type the name of the .dat file: ");
                     inFile = console.readLine();
                     System.out.print("Please type the name for the .txt file (Output): ");
                     outFile = console.readLine();
                  catch(IOException e) {
                          System.err.println("Problem with input: " + e);
                     System.exit(1);
               else {
                  inFile = args[0];
                  outFile = args[1];
               try {
                 //inFileReader = new ObjectInputStream(inFile);
                  //inFileBuffered = new BufferedReader(inFileReader);
                  //ObjectInputStream inFileReader = null;
                   //BufferedReader inFileBuffered = null;
                  //Input Streams:
                   FileInputStream obj = new FileInputStream(inFile);
                   ObjectInputStream in = new ObjectInputStream(obj);
                    //output stream:
                    FileWriter out = new FileWriter(outFile);
                  String name = null;
                  Double salary = 0.0;
                  Employee temp = (Employee)in.readObject();
                  Class nameClass = temp.getClass();
                  temp = new Employee("SallyJones", 23456);
                  while(temp != null){
                      name = (String)temp.getName();
                      salary = (Double)temp.getSalary();
                        out.write(name + " - " + salary);
                       temp = (Employee)in.readObject();
              catch(FileNotFoundException e){
              System.err.println("File not found: " + e.toString());
              catch(IOException e){
                   System.err.println("Error with file: " + e.toString());
                   e.printStackTrace();
              catch(IndexOutOfBoundsException e){
                   System.err.println("Index is out of Bounds: " + e.toString());
                   e.printStackTrace();
              catch(NullPointerException e){
                   System.err.println("Error with String(NullPointerException):" + e);
                   e.printStackTrace();
              catch(ClassNotFoundException e){
                   System.err.println("Error with Class: " + e);
                   e.printStackTrace();
    }

  • Problems with running Applet through HTML

    I am currently having problems with running my file through the HTML. For some reason when I open it in the browser it keeps saying Error. I am programming in NetBeans.
    The code I am using is:
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <applet code=”CarApplet.class” codebase="RedCarApplet.jar" width=690 height=300></applet>
    </body>
    </html>

    Heres the error message, I see that it cannot find the class I have stated above. Any solutions?
    My class is in the 'build' folder but, the HTML file is in the 'src' folder. Now my applet contains a 'jar' file, do I need to add that to the HTML code?
    load: class ‚Ä?TunerApplet.class‚Ä? not found.
    java.lang.ClassNotFoundException: ‚Ä?TunerApplet.class‚Ä?
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\Users\*****\*******\NetBeansProjects\RadioApplet\src\‚Ä?TunerApplet\class‚Ä?.class (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 9 more
    Exception: java.lang.ClassNotFoundException: ”TunerApplet.class”

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

Maybe you are looking for