Problem During reading and write local file

Hi ,
I had written a small applet program, it have function �readNwriteFile()� it read/write the local file
This function works fine when I call it from start () function.
But whenever I was trying to call this function from java script it gave me this exception.
�java.security.AccessControlException: access denied (java.io.FilePermission C:\temp_jar\DSC01692.JPG read)�.
Java script is working fine, I can access any another function from script The problem is some related to access
I had set the permission in my policy file .this the permission that I had set.
grant codebase "file:c:\temp_jar"{
permission java.io.FilePermission "<< ALLFILES >> , "read ,write ,delete ,execute ";
Java code.
package com.ravindra;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*;
public class MialTest extends JApplet{
     public void init() {
     public void start(){
          readNwriteFile(); /// When I call this function from here It is working
     public byte [] readNwriteFile(){
          try {
               File localfile = null;
               localfile = new File("C:\\temp_jar\\DSC01692.JPG");
               FileInputStream fs = new FileInputStream(localfile);
               ByteArrayOutputStream bs = new ByteArrayOutputStream() ;
               int actual_data = (int)fs.read();
               while(actual_data > -1){
                    bs.write(actual_data);
                    actual_data = (int)fs.read();
               byte [] final_data = bs.toByteArray();
               File out_file = new File("C:\\temp_jar\\Ravindra_test.JPG");
               FileOutputStream out_stream = new FileOutputStream(out_file);
               out_stream.write(final_data);
               out_stream.flush();
               fs.close();
               bs.close();
               localfile = null;fs = null; bs = null;
               return final_data;
          } catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               return null;
Java Script Code:

Hi ,
I had written a small applet program, it have function �readNwriteFile()� it read/write the local file
This function works fine when I call it from start () function.
But whenever I was trying to call this function from java script it gave me this exception.
�java.security.AccessControlException: access denied (java.io.FilePermission C:\temp_jar\DSC01692.JPG read)�.
Java script is working fine, I can access any another function from script The problem is some related to access
I had set the permission in my policy file .this the permission that I had set.
grant codebase "file:c:\temp_jar"{
permission java.io.FilePermission "<< ALLFILES >> , "read ,write ,delete ,execute ";
Java code.
package com.ravindra;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*;
public class MialTest extends JApplet{
     public void init() {
     public void start(){
          readNwriteFile(); /// When I call this function from here It is working
     public byte [] readNwriteFile(){
          try {
               File localfile = null;
               localfile = new File("C:\\temp_jar\\DSC01692.JPG");
               FileInputStream fs = new FileInputStream(localfile);
               ByteArrayOutputStream bs = new ByteArrayOutputStream() ;
               int actual_data = (int)fs.read();
               while(actual_data > -1){
                    bs.write(actual_data);
                    actual_data = (int)fs.read();
               byte [] final_data = bs.toByteArray();
               File out_file = new File("C:\\temp_jar\\Ravindra_test.JPG");
               FileOutputStream out_stream = new FileOutputStream(out_file);
               out_stream.write(final_data);
               out_stream.flush();
               fs.close();
               bs.close();
               localfile = null;fs = null; bs = null;
               return final_data;
          } catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               return null;
Java Script Code:

Similar Messages

  • Java Applet: choose, read and write local file

    Can some body please help in writing a Java Applet with the following features:
    1. FileChooser button to select a local text file
    2. Load button
    3. Read the file line by line, process it and write into a text file.

    AnilK wrote: Thank you very much.
    Those are just empty words. You can show your thanks in ways that are more useful both to me and you.
    To better show your thanks you might..
    1) Stop treating me as though I were your servant. In a conversation, you might ask a question that I try to answer. As part of my answer, I might need to ask you some questions. A question is a sentence followed by '?'. I did ask you some questions. There are four questions I asked in my first reply. Please answer my questions so I can provide you the best advice.
    2) Do not ignore things I say. (see below*)
    AnilK wrote: However, I still have a problem where the applet can not write a local text file.
    * That is probably because you ignored what I mentioned about digitally signing the applet. If you do not understand anything I write, please do a search and if that does not help you to understand it, ask me what I mean.
    AnilK wrote: Can some body please help me out.
    I was happy to help, but my enthusiasm is dropping quickly. Unless you can manage to improve your replies, I will not help further.
    I will supply some more tips before I finish this message and wait to see your reply, to decide whether I will help further.
    1) If you use 'code' delimiters, the Java code will be colored nicely for people to read. Here is an example (e.g.).
    } catch (Exception e) {
    ret = "problem found. Please reload.";
    return ret;
    2) I had a point here about indenting code, but when I went to reply, the code was indented, which makes me think that using code delimiters would also fix the problem where the code looks as if it has no indentation.
    3) It is 'best practice' (unless you are an expert and can justify otherwise) to dump every stacktrace to find out what really happened. e.g.
      } catch (Exception e) {
        // Very important!  Find out why it failed!
        e.printStackTrace();
        // now go on to do the other things..
        ret = "problem found. Please reload.";
      return ret;
    } 4) When you get a stacktrace, copy/paste at least the first few lines into the message. If my guess about the cause of the problem is correct, the word 'security' will appear somewhere in the stacktrace.
    5) To encourage people to help, post compilable examples, rather than code snippets.
    <http://homepage1.nifty.com/algafield/sscce.html>
    By the way - congratulations on getting as far as you have. You have surprised me that you got so far already. Improve on the other things I mentioned, and I would be happy to help further.

  • File Read and Write using File Adapter in Bpel

    In Bpel Process i am using File Adapter ( Schema is Opaque) for read and write the file contents. i am able do successful deployment and read, write function in first time deployment, after that again i tired to run the application, its not going to write the content of file, its only writing the file with out data's or content in that file.
    Please help me...
    Saravanan

    Hi Eric
    In my domain.log file having the following details. In this file im unable to find out what the exact problem. Please look at this and help me.
    <2008-01-22 18:25:42,024> <INFO> <default.collaxa.cube.compiler> validating "C:\product\10.1.3.1\OracleAS_1\bpel\domains\default\tmp\.bpel_BPELProcess2_1.1_298e83988d77b6640c33dfeec11ed31b.tmp\BPELProcess2.bpel" ...
    <2008-01-22 18:25:49,850> <INFO> <default.collaxa.cube.engine.deployment> <CubeProcessFactory::generateProcessClass>
    Process "BPELProcess2" (revision "1.1") successfully compiled.
    <2008-01-22 18:25:49,914> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Loading JCAActivationAgent for {portType=Read_ptt}
    <2008-01-22 18:25:49,914> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::load - Locating Adapter Framework instance: OraBPEL
    <2008-01-22 18:25:49,930> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::load - Done loading JCAActivationAgent for processId='bpel://localhost/default/BPELProcess2~1.1/
    <2008-01-22 18:25:49,930> <INFO> <default.collaxa.cube.engine.deployment> Process "BPELProcess2" (revision "1.1") successfully loaded.
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::uninit Shutting down the JCA activation agent, processId='bpel://localhost/default/BPELProcess2~1.0/', activation properties={portType=Read_ptt}
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - performing endpointDeactivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Endpoint De-activation called in adapter for endpoint : D:\MAXIMUS_Project_Softwares\jdevstudiobase10132\jdev\mywork\MyLabs\BPELProcess2\in
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::init - Initializing the JCA activation agent, processId='bpel://localhost/default/BPELProcess2~1.1/
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::initiateInboundJcaEndpoint - Creating and initializing inbound JCA endpoint for:
    process='bpel://localhost/default/BPELProcess2~1.1/'
    domain='default'
    WSDL location='rd.wsdl'
    portType='Read_ptt'
    operation='Read'
    activation properties={portType=Read_ptt}
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - endpointActivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,730> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Endpoint Activation called in File Adapter for endpoint: D:\MAXIMUS_Project_Softwares\jdevstudiobase10132\jdev\mywork\MyLabs\BPELProcess2\in
    <2008-01-22 18:26:02,730> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - successfully completed endpointActivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,890> <WARN> <default.collaxa.cube.activation> <File Adapter::Inbound> PollWork::run exiting, Worker thread will die
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Managed Connection Created
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Connection Created
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> FileInteraction Created

  • How do I migrate files created in a Windows OS to a new external drive that is formatted as a MAC drive. I want to read and write these files back to the new drive.

    How do I migrate files from an external hard drive created in a Windows OS to a new MAC external drive? I want to read and write these files to the new drive.

    LKrzesowski wrote:
    How do I migrate files from an external hard drive created in a Windows OS to a new MAC external drive? I want to read and write these files to the new drive.
    If all you're trying to do is move the files from the Windows external to the Mac external, you can simply connect them both to the Mac and drag the files from the Windows drive to the Mac drive. If you want to move the files back and forth between them, you'll need to establish the format of the Windows external. Macs can read and write to FAT32 and exFAT (which can handle files larger than 4GB) formatted drives but can only read NTFS formatted drives without additional software. With the Windows drive connected, you can check its format with Disk Utility.

  • I'm trying to share folder between users on a single mac.  I put the folder in "shared," set permissions so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    I'm trying to share a folder between users on a single mac.  I want both users to be able to read and write so the folder stays current on both accounts.  I put the folder in "shared," set permissions on folder so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    Did you log out of one account and into the other or just used Fast user switching?
    Is the permissions set to anyone?
    When you move data to teh Shared folder is it copied or just moved?
    If copied then it's not a folder both can access, just a way station like a USB thumb drive that things are coped too and off of likely.
    You can run this #5 on each user account to reset the user permissions once they are taken back out of the Shared folder
    Step by Step to fix your Mac

  • How to read and write a file in unicode?

    Hello!
    I have a problem with reading and writing files which are saved in unicode. with my current code I get strange boxes in my text
    Do you need a special Reader/Writer for this?
    Please, help me if you have any ideas.
    cheers
    import java.io.*;
    import java.util.*;
    public class StreamConverter {
       static void writeOutput(String str) {
           try {
               FileOutputStream fos = new FileOutputStream("test_uni.txt");
               Writer out = new OutputStreamWriter(fos, "UTF8");
               out.write(str);
               out.close();
           } catch (IOException e) {
               e.printStackTrace();
       static String readInput() {
          StringBuffer buffer = new StringBuffer();
          try {
              FileInputStream fis = new FileInputStream("file_uni.txt");
              InputStreamReader isr = new InputStreamReader(fis, "UTF8");
              Reader in = new BufferedReader(isr);
              int ch;
              while ((ch = in.read()) > -1) {
                 buffer.append((char)ch);
              in.close();
              return buffer.toString();
          } catch (IOException e) {
              e.printStackTrace();
              return null;
       public static void main(String[] args) {
            String inputString = readInput();
            writeOutput(inputString);     
    }

    Are you saying there's only the three boxes at the beginning, and the rest of the text is okay? That sounds like a Byte Order Mark (BOM). The BOM is optional for UTF-8, but Java's I/O classes act like it's forbidden. They should check for it when reading so they can skip over it, but (for now, at least) we have to do that ourselves.
    All you have to do is read the first three bytes from the InputStream and compare them to the BOM. If they match, you start reading the text from that position; otherwise you reset the InputStream and start reading from the beginning.
    http://en.wikipedia.org/wiki/Byte_Order_Mark

  • How to read and write(a file .txt) from a URLConnection

    I try to read and write on one URLConnection. Is it possible ? How can i make it ?
    The reading part of my application work's but not the writting part
    That's a part of rhe code that i use to write :
    String Line = "Hi";
    MyUrl = new URL(this.getCodeBase(), FichierEvenement) ;
    Con = MyUrl.openConnection() ;
    Con.setDoOutput(true);
    Con.setDoInput(true);
    Con.setUseCaches(false);
    Dos = new DataOutputStream(new BufferedOutputStream(Con.getOutputStream( )));
    Dos.writeUTF(Line);
    Please help me :)

    What are you doing with the bytes written to the OutputStream? This info would help, but i do have a suggestion. I ran into this problem when trying to write strings using writeUTF. The output was all screwed up. So, maybe change your string to a character array. That way Unicode is displayed properly. This in conjunction with writing to an .html file instead of to the connection itself might work.

  • How to read and write to file on server

    can any body tell how to read or write to a file on server, like where do i keep the file and what does the path look like......on server
    stand alone i am reading and writing into file but when it comes to server i am confused how it works...i mean the path
    thank you

    The Path needs to be absolute:
    For example in Unix it would look like:
    /usr/paz/Test.txtIn Windows it would look like:
    C:/Paz/Test.txtHope this helps.
    Thanks and regards,
    Pazhanikanthan. P

  • Multithreaded problem in read and write thread

    This is a producer consumer problem in a multi-threaded environment.
    Assume that i have multiple consumer (Multiple read threads) and a
    single producer(write thread).
    I have a common data structure (say an int variable), being read and written into.
    The write to the data sturcture happens occasionally (say at every 2 secs) but read happens contineously.
    Since the read operation is contineous and done by multiple threads, making the read method synchronized will add
    overhead(i.e read operation by one thread should not block the other read threads). But when ever write happens by
    the write thread, that time the read operations should not be allowed.
    Any ideas how to achive this ??

    If all you're doing is reading an int, then just use regular Java synchronization. You'll actually get a performance hit if you're doing simple read operations, as stated in the ReadWriteLock documentation:
    Whether or not a read-write lock will improve performance over the use of a mutual exclusion lock depends on the frequency that the data is read compared to being modified, the duration of the read and write operations, and the contention for the data - that is, the number of threads that will try to read or write the data at the same time. For example, a collection that is initially populated with data and thereafter infrequently modified, while being frequently searched (such as a directory of some kind) is an ideal candidate for the use of a read-write lock. However, if updates become frequent then the data spends most of its time being exclusively locked and there is little, if any increase in concurrency. Further, if the read operations are too short the overhead of the read-write lock implementation (which is inherently more complex than a mutual exclusion lock) can dominate the execution cost, particularly as many read-write lock implementations still serialize all threads through a small section of code. Ultimately, only profiling and measurement will establish whether the use of a read-write lock is suitable for your application.

  • How to read and write Xml file at client side using JavaScript !

    Hello,
    i am new to javascript.
    I have requirement to read and update XML file at client side.
    Will you please guide what could be the best way to read and update XMl file using javascript.
    Thanks,
    Zuned

    This is a Java forum,not a Javascript forum. Maybe you should ask here [http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s|http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s].

  • Read and Write XML files

    I work on a Flex application that will be used to record time entries for manufacturing plan. I have two problems to solve:
    1- Can I read an XML file from a local drive? (C: /temp/file)
    2- If the system where I call the web service is offline, I must create local file that are going to be read later vwhen the system will be up again. How can I create local file from Flex?

    A web-based app cannot access the local drive w/o user permission.
    Sometimes, folks upload local files to a server (also requiring user
    permission) and then request the file from the server.
    You can use local SharedObject to store data, although there are limits to
    how much data.
    The recommended option is to create an AIR app.  It will be able to access
    the local drive once it is installed.

  • I have an excel file,i want to read and write this file to xml

    hello,
    i have an excel file,i want to read excel data and write to xml file .i also have an exisitng xml file and i want to appened the excel data to the exisiting xml.please give some example code.
    thanks

    GoOgLe

  • Read and Write Excel File

    Hi all. I need your need help. I need to know how to read EXCEL FILE and insert it to a certain table. By the way, can anyone tell me how to write to a EXCEL FILE?
    Thank you in advance.

    READING EXCEL
    There are several options how to read excel file - ODBC, on a fly excel-->CSV conversion (if you have 11.2 and want to use external tables preprocessor), ... I put (I think all) options on my BLOG http://jiri.wordpress.com/2010/01/04/load-ms-excel-file-to-oracle-database/
    WRITING TO EXCEL
    Writing to excel is tricky because there is no direct way from Oracle, here are few tips
    1. JAVA - you can create java stored procedure, I did not test this but it's probably doable http://www.java-tips.org/other-api-tips/jexcel/how-to-create-an-excel-file.html
    2. Excel XML format - you can use UTL_FILE and write to XML format Excel can read http://blogs.msdn.com/b/brian_jones/archive/2005/06/27/433152.aspx
    3. Excel can also read CSV files, but it's plan text file with no formatting. You can use UTL_FILE to easily create CSV (comma separated) file and read it from excel, I have few samples on my blog http://jiri.wordpress.com/2009/03/18/oracle-fast-parallel-data-unload-into-ascii-files/

  • Problem to read and write files on hdd out of html with an Applet ????

    hi there,
    i wrote an applet for loading a file from HDD or saving data out of a cookie in a file on a hdd.
    when i compile the class there are warnings about "unchecked method invocation" and "unchecked conversion".
    what did i do wrong?
    i think it's about this function:
    AccessController.doPrivileged(new PrivilegedAction()
    public Object run()
    if(saveCartAtOnce.toLowerCase().compareTo("true")== 0)
    SaveShoppingCart();
    }//if
    return null;
    }// public Object run
    });//AccessController
    could anyone help me?
    i could also send the whole class then....
    thanks a lot.
    greetings
    Volker Becht
    [email protected]

    OK
    now i will post the whole class.
    my questen is: what have i to do so that anything runs?
    if anyone will need a file example which should be read
    into the calss i will email it.
    package de.CATALOGcreator.shoppingcart;
    import java.awt.*;
    import java.io.*;
    import java.applet.*;
    import java.util.*;
    import java.security.*;
    import netscape.javascript.*;
    public class shoppingcart extends java.applet.Applet
         private static final long serialVersionUID = 1234567890L;
       //Explanation of the possible Parameters of the applet, all of the following
        //parameters need not be given explicitely, because they have default values.
        String errorMessageInvalidFileFormat = "";  //set the ErrorMessage String for InvalidFileFormat when loading
        String openDialogTitle = "";                //set the Open Dialog Title
        String saveDialogTitle = "";                //set the Save Dialog Title
        String articleNumberString = "";            //set the ArticleNumber of the CSV headline
        String articleNameString = "";              //set the ArticleName of the CSV headline
        String amountString = "";                   //set the AmountName of the CSV headline
        String priceString = "";                    //set the PriceName of the CSV headline
        String delimiterString ="";                 //set the Delimiter for the Output-csv
        String inputdelimiterString ="";            //set the Delimiter for the Intput-csv
        //No parameter, this String is built from articleNumberString, articleNameString, amountString and
        //priceString and delimiterString in the following manner:
        //headline = articleNumberString + delimiterString + articleNameString + delimiterString + amountString+ delimiterString  + priceString;
        //see: init();
        String headline = "";                       //set the Headline of the csv-file
        //Another parameter is saveCartAtOnce, which says, if the save-Dialog is schown
        //at once when the applet is initialized. If the value is "true", the dialog shows
        //at once, in all other cases (also if parameter does not exist) you have to
        //call SaveShoppingCart explicitely.
        String saveCartAtOnce;
       public void init()
            try
                   //set the default setting for the Paramters
                   openDialogTitle = this.getParam("openDialogTitle", "Open Shopping Cart");
                   saveDialogTitle = this.getParam("saveDialogTitle", "Save File As");
                   errorMessageInvalidFileFormat = this.getParam("errorMessageInvalidFileFormat", "Invalid File Format!\nLoading stopped.");
                   delimiterString = this.getParam("delimiterString", "||");
                   inputdelimiterString= this.getParam("inputdelimiterString", ",");
                   articleNumberString = this.getParam("articleNumberString", "Article Number");
                   articleNameString = this.getParam("articleNameString", "Article");
                   amountString = this.getParam("amountString", "Amount");
                   priceString = this.getParam("priceString", "Price");
                   headline = articleNumberString + delimiterString + articleNameString + delimiterString + amountString + delimiterString  + priceString;
                   saveCartAtOnce = this.getParameter("saveCartAtOnce");
                   AccessController.doPrivileged(new PrivilegedAction()
                                  public Object run()
                                       if(saveCartAtOnce.toLowerCase().compareTo("true")== 0)
                                            SaveShoppingCart();
                                            //LoadShoppingCart();
                                       }//if
                                       return null;
                                  }// public Object run
                   });//AccessController
              catch(Exception e)
                   e.printStackTrace();
        }//void init
        public void  SaveShoppingCart()
            DataOutputStream dos;
            String myFile;
            File f ;
             myFile =  SaveDialog();
               if(myFile!=null)
                    f = new File(myFile);
                   String Artikel=getParameter("Artikel");
                   String Anzahl=getParameter("MyAnzahl");
                   String Bezeichnung=getParameter("Bezeichnung");
                   String Preis=getParameter("Preis");
                   StringTokenizer stArticle = new StringTokenizer(Artikel, inputdelimiterString);
                   StringTokenizer stAnzahl = new StringTokenizer(Anzahl, inputdelimiterString);
                   StringTokenizer stBezeichnung = new StringTokenizer(Bezeichnung, inputdelimiterString);
                   StringTokenizer stPreis = new StringTokenizer(Preis, inputdelimiterString);
                   JSObject.getWindow(this).eval("alert('"+ Artikel +"')");
                     try
                          dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
                          // Line 1
                        dos.writeChars(headline + "\n");
                          while (stArticle.hasMoreTokens())
                              String tmpArticle=stArticle.nextToken();
                              String tmpAnzahl=stAnzahl.nextToken();
                              String tmpBezeichnung=stBezeichnung.nextToken();
                              String tmpPreis=stPreis.nextToken();
                              dos.writeChars(tmpArticle + delimiterString + tmpBezeichnung + delimiterString +tmpPreis +  delimiterString + tmpAnzahl + "\n");
                        }//while
                          dos.flush();
                          System.out.println("Successfully wrote to the file named " + myFile + " -- go take a look at it!");
                          dos.close();
                   }//try
                      catch (SecurityException e)
                        System.out.println("JavaSoft SaveShoppingCart: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
                        e.printStackTrace(System.out);
                   }//catch
                   catch (IOException ioe)
                        System.out.println("JavaSoft SaveShoppingCart: IOexception\nMessage:" + ioe.getMessage() + "\nStackTrace:");
                        ioe.printStackTrace(System.out);
                   }//catch
              }//if
        }//void  SaveShoppingCart
        private String SaveDialog()
            try
               //Date now = new Date(System.currentTimeMillis());
                Calendar rightNow = Calendar.getInstance();
               //SystemDate
                //String strDay = Integer.toString(now.getDate());
                String strDay = Integer.toString(rightNow.get(Calendar.DAY_OF_MONTH));
                //String strMonth = Integer.toString(now.getMonth()+1);
                String strMonth = Integer.toString(rightNow.get(Calendar.MONTH));
                //String strYear = Integer.toString(now.getYear()+1900);
                String strYear = Integer.toString(rightNow.get(Calendar.YEAR));
                //SystemTime
                //String strHoure = Integer.toString(now.getHours());
                String strHoure = Integer.toString(rightNow.get(Calendar.HOUR));
                //String strMinutes = Integer.toString(now.getMinutes());
                String strMinutes = Integer.toString(rightNow.get(Calendar.MINUTE));
                //String strSeconds = Integer.toString(now.getSeconds());
                String strSeconds = Integer.toString(rightNow.get(Calendar.SECOND));
                //set SystemDate+SystemTime
                String strDate=strDay+"_"+strMonth+"_"+strYear+"_"+strHoure+"_"+strMinutes+"_"+strSeconds;
                //set SaveName as *.csv
                String SaveAs = strDate + ".csv";
                FileDialog fd = new FileDialog (new Frame(), "Save File As", FileDialog.SAVE);
                fd.setFile(SaveAs);
                fd.setVisible(true);
                //Value Save or Cancel Button
                if((fd.getDirectory() == null) || (fd.getFile() == null)) // user pressed the cancel - button
                    return null;
                }//if
                else // user pressed save - button
                    return fd.getDirectory() + fd.getFile();
                }//else
            }//try
            catch (SecurityException e)
                   System.out.println("JavaSoft String SaveDialog: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
                   e.printStackTrace(System.out);
                  return null;
            }//catch
        }// String SaveDialog
        public String OpenDialog()
               FileDialog fd = new FileDialog (new Frame(), openDialogTitle, FileDialog.LOAD);
               fd.setVisible(true);
               return fd.getDirectory() + fd.getFile();
        }//String OpenDialog
        private String getParam( String paramName, String defaultValue )
              String value = getParameter( paramName );
              if ( value != null )
                   return value;
              }//if
              return defaultValue;
        }//String getParam
        public void LoadShoppingCart()
            String myFile;
            File f ;
            myFile =  OpenDialog();
            if(myFile!=null)
                   f = new File(myFile);
                   String rl = "";
                   Object[] Obj = new Object[2];
                   try
                        DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(myFile),128));
                        // Line 1
                        String FirstLine = myReadLine(dis);
                        JSObject.getWindow(this).eval("alert('"+ FirstLine +"')");
                        if(FirstLine.startsWith(headline))
                             while ( (rl = myReadLine(dis)) != null)
                                  //examines correct delimiter
                                  StringTokenizer token = new StringTokenizer (rl, delimiterString);
                                  if(token.countTokens()!= 4)
                                       dis.close();
                                       JSObject.getWindow(this).eval("alert('"+ errorMessageInvalidFileFormat +"')");
                                  }//if
                                Obj[0]= (Object)rl;
                                Obj[1]= (Object)delimiterString;
                                JSObject.getWindow(this).call("addCSVArticle",Obj); // this=applet
                             }//while
                             JSObject.getWindow(this).call("importFinished",null);
                        else
                             dis.close();
                             JSObject.getWindow(this).eval("alert('"+ errorMessageInvalidFileFormat +"')");
                             //System.exit(-1);
                        }//else
                        dis.close();
                   }//try
                      catch (SecurityException e)
                        System.out.println("JavaSoft LoadShoppingCart: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
                        e.printStackTrace(System.out);
                   }//catch
                   catch (IOException ioe)
                        System.out.println("JavaSoft LoadShoppingCart: IOexception\nMessage:" + ioe.getMessage() + "\nStackTrace:");
                        ioe.printStackTrace(System.out);
                   }//catch
                   catch(Exception exc)
                        System.out.println("JavaSoft LoadShoppingCart: Exception\nMessage:" + exc.getMessage() + "\nStackTrace:");
                        exc.printStackTrace(System.out);
                   }//catch
              }//if
        }//void LoadShoppingCart
        private String myReadLine(DataInputStream dis)
            char tmp;
            String line = "";
            try
                while((tmp = dis.readChar())!= '\n')
                    line += tmp;
                return line;
            }//try
            catch(IOException ioexc)
                return null;
            }//catch
        }//String myReadLine
        public boolean isInitialized()
              return true;
    }//public class ShoppingCart extends java.applet.Applet[/i]

  • Read and Write Binary File

    Hi...
    I have a problem. In C programming, if we want to read a file, we can determine to read it as text or binary. There is difference between them. But we still can read it in ASCII mode.
    My problem is :
    How to do that in Java ? I want to read any file in binary and I hope can read it in ASCII(8 bit) mode.
    I need it...
    Thanks for your help

    Hi,
    Check this link
    http://saeta.physics.hmc.edu/courses/p170/code/files.html#Java
    Gives you an example where you can see how to open a files for input or output in Binary or text mode.
    Hope this helps.
    Regards,
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

Maybe you are looking for

  • Scheduling InfoPackage fails to start extract in R/3

    Hi, We are extracting data from CO-PA using the delta infosource. We initialised the Delta successfully (without data transfer) and have now scheduled our infopackage to extract data from R/3. When we go to monitor, it tells us that the "Request is s

  • Discount calculation

    Hi experts Our client current scenario is the discount is calculated after adding up all the tax amount ie(CESSBEDHecess),but in SAP B1  the discount is calculated before  the tax amount  ,like to know how configure the discount amount after the taxe

  • Use of Attributes in the following table

    Could anyone please specify the use of each attribute in the follwoing Table All_clusters All_source All_triggers Dba_external_Tables Dba_source Dba_triggers User_indexes User_Source User_triggers V$session Thanks in Advance

  • Upgrade Exchange 2010 SP2 to SP3 getting fail

    Hi, I am trying to upgrade from exchange 2010 SP2 to SP3, but it getting failed. I have already run the prepare schema, prepare and domain prep in all domains and it got replicated in DR Domain controllers. But, still i am not able to upgrade the ser

  • Will Lightroom 4 support custom XMP?

    XMP stands for eXtensible Metdadata Platform. Supposedly it is a standard developed by Adobe that permits image metadata not just be locked into one rather limited core set of fields like IPTC, but the design of custom metadata panels that in theory