Please Give me advice

* @(#)FileTest.java 1.0 07/08/01
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Template_1\Project_Name.java
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
package myprojects.filetest;
import java.awt.*;               // container,FlowLayout
import java.awt.event.*;     //ActionEvent,ActionLIstener
import java.io.*;
import javax.swing.*;
public class FileTest extends JFrame implements ActionListener{
     private JTextField enterField;
     private JTextArea outputArea;
// set up GUI
     public FileTest()
          super("Testing File");
          enterField=new JTextField("Enter Fiel or name directory here");
enterField.addActionListener(this);     
          outputArea=new JTextArea();
          ScrollPane scrollPane = new ScrollPane();
          scrollPane.add(outputArea);
          Container container = getContentPane();
          container.add(enterField,BorderLayout.NORTH);
          container.add(scrollPane,BorderLayout.CENTER);
          setSize(400,400);
          setVisible(true);
     }//end constructor
     //display information about file user specifies
     public void actionPerformed(ActionEvent actionevent)
          // if name exists , output information about it
          File name = new File(actionevent.getActionCommand());
          if (name.exists()){
               outputArea.setText(name.getName()+"exists\n"+
               (name.isFile()?"is a File\n":"is not a file\n")+
               (name.isDirectory()?"is a Directory\n":"is not a directory\n")+
               (name.isAbsolute()?"is Abslutepath\n":"is not Abslute path\n")+
               "Last modified\n"+name.lastModified()+
               "\nLength:"+name.length()+"\nPath"+name.getPath()+
               "\nAbslute path:"+name.getAbsolutePath()+
               "\nParent:"+name.getParent());
               //output information if name is file
               if(name.isFile()){
                    //appen content of file to outputArea
                    try{
                         BufferedReader input = new BufferedReader(new FileReader(name));
                         StringBuffer buffer= new StringBuffer();
                         String text;
                         outputArea.append("\n\n");
                         while((text=input.readLine())!=null)
                         buffer.append(text+"\n");
                         outputArea.append(buffer.toString());
                    //process file processing problems
                    catch(IOException ioException){
                         JOptionPane.showMessageDialog(this,"file error",
                         "fil error",JOptionPane.ERROR_MESSAGE);
               }//end if
               //output directory listing
                    else if(name.isDirectory()){
                         String directory[]=name.list();
                         outputArea.append("\n\nDirectory constant:\n");
                         for(int i=0;i<directory.length;i++)
                         outputArea.append(directory[i]+"\n");
               }// end outer if
               // not file or directory , output error message
               else{
                    JOptionPane.showMessageDialog(this,
                    actionevent.getActionCommand()+
                    "Does Not Exist","Error",JOptionPane.ERROR_MESSAGE);
          }// end method actionperformed
               public static void main(String args[])
                    FileTest application= new FileTest();
          }// end class FileTest
this program run prefectly
but my problem
is when
i write
the file name , the program dive me an error message .
this message i made it to appear when the file i write in the textField
is wrong put i wrote the file right and give me an error message.
please run this code to understande the program
then write to me the coorect way that can i write
the file .
thanks

Advice: Format thy code.
Advice: Saying "the program gives me an error message." is a sure-fire way to annoy the hell out of people around here. Try pasting the error message and the line that it refers to. If you don't take the time to help us help you, chances are we won't.

Similar Messages

  • Please give me advices when to use black and white sliders in LR4.

    Please give me advices when to use black and white sliders in LR4.

    I use blacks and white sliders on every photo (this does not necessarily imply non-zero values). I consider them as important as any other slider. Not optional, not for fine tuning - include consideration each iteration.
    Although that is contrary to what Adobe and many "experts" recommend, I tried doing it their way too but I could not get the results I wanted in most cases.
    The "concept" and original intent is for fine tuning, but the implementation is not. I often set whites to +20, +30, +40. This has a radical effect on overall exposure which is the most important thing to get right in PV2012. And it generally requires compensatory adjustment of highlights, shadows, and sometimes contrast...
    Likewise, optimal shadow toning can include radical blacks adjustment  - sorry Adobe/experts/defenders, but for me - it's true. And, blacks slider, like whites, affects entire histogram, a lot.
    Summary:
    ========
    If you want to keep things as simple as possible, then use sparingly and use last (gag), but if you want your photos to look how you want them to look - as good as possible, then use liberally, and pay the price...
    More info here: http://forums.adobe.com/message/4259091#4259091
    Rob

  • Please give me advice about....what is the best virus guard in store and is virus worked in iPhone (my English is not good sorry)

    Please give me advice about....what is the best virus guard in store and is virus worked in iPhone (my English is not good sorry)

    If you are gettin spammed via e-mail or text that your IOS has a virus (usually says call some 800 number) then these are a scam - do NOT contact these crooks

  • Please give any advice thanks from Susan

    hI we have had trouble with are new printer we have had it for about a month now but we can't print anything of it we have tried wireless and downloading the app but had no luck please give any advice thanks from Susan

    Hello @Susanpurdy!
    Thanks for posting on the HP Forums!
    I would be happy to provide some help!  I can see that you are unable to print anything to the Deskjet 2540 via wireless.  To ensure I provide you with the correct information I will need to know what operating system the computer running.  also are you trying to print from a mobile device like an iPad or tablet? 
    If you are unsure of what operating system version your computer is running:
    For Windows click here:  Windows Operating System
    For Mac click here: Mac Operating System
    To ensure your router is setup to network the printer correctly I recommend contacting your router company an ensure  the following settings are correct in the router:
    ~ Network name and password need to have NO SPACES OR PUNCTUATION
    ~ Must be using WPA security
    ~ Encryption Type 128-bit
    ~ Dual broadcast Wireless b/g/n (printer will only connect to g)
    ~ MAC filter needs to be turned off
    ~ Multicasting Must be turned on
    ~ Bonjour must be enabled
    ~ Dual band set to 2.4 Ghz
    ~ Correct Wireless Channel (not 1,, 6,, 11)
    ~ Router Firmware Updates
    ~ Firewall settings need to be at there default settings, or set to a lower security
    ~ Following ports need to be un-blocked:
    Incoming (UDP) ports : 137, 138, 161, 427 (iPad 80, 443)
    Outgoing (TCP) ports : 137, 139, 427, 9100, 9220, 9500 (iPad 5222, 5223)
    Please post back with the requested ifnormation and i should be able to provide more help!
    Cbert
    I work on behalf of HP.
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" at the bottom of this post to say “Thanks” for helping!

  • My macbook is five years old and has become slow. often displays the whirling kaleidoscope. can anyone please give me advice on what to do?

    My macbook is five years old and has become slow. often displays the whirling kaleidoscope. can anyone please give me advice on what to do?

    Quite often the HDD is the source of the problems.  Look at this comprehensive guide for possible solutions:
    https://discussions.apple.com/docs/DOC-3521
    Ciao.

  • My video is a finalist in a big contest! Please give me advice on winning!

    Here is a link to my video I edited in FCP. It is the bottom row, third one in (white guy with black polo) and i was wondering what you guys think of it! Also, since you all have made video before, what techniques have you used to spread around a video and have people vote on it?!
    http://www.bragadoo.com/braganaire/vote/
    P.S- if u like it, please do vote for it

    As long as you have warranty coverage Australian, then both of these problems are covered.
    You can determine whether your machine is eligible for warranty in Australia, by checking the following website.
    http://www-307.ibm.com/pc/support/site.wss/documen​t.do?lndocid=LOOK-IWS#sw
    Issue 1, requires you to send the laptop to the depot (once you contacted Lenovo warranty on 131-426, they will arrange pick up and delivery to the nearest depot using DHL Express).
    Issue 2, can be resolved through Lenovo service sending out the replacement drive to you (you can request a set of recovery media, if you haven't made one already), and you give the courier (Toll Priority) the broken one.
    Regards,
    Jin Li
    May this year, be the year of 'DO'!
    I am a volunteer, and not a paid staff of Lenovo or Microsoft

  • Why my firefox cant open and when i checking my ccleaner said the mozilla firefox still running . please give me advice

    please advice me please :(

    Check your firefox running in background
    *https://support.mozilla.org/en-US/kb/firefox-already-running-not-responding
    *http://kb.mozillazine.org/Firefox.exe_always_open

  • I have a Mac OS X 10.6.7 and Firefox 4. Other browser are easily connecting to the net but Firefox. It keep trying to connect to my wireless network but not doing the job. Please give some advice..

    This happens when I first start the computer. Sometimes it connects to the wireless network, and during the day is fine.

    user8744713 wrote:
    I have downloaded Instant Client libraries (basic, SDK and SQL files, named instantclient-basic-10.2.0.4.0-macosx-x64.zip , instantclient-sqlplus-10.2.0.4.0-macosx-x64.zip and instantclient-sqlplus-10.2.0.4.0-macosx-x64.zip ) to Mac OS X 10.6.2 server and unzipped them as instructed in the manual here: http://download.oracle.com/docs/cd/B19306_01/install.102/e12121/inst_task.htm#BABJGGJH
    Manual then instructs to run runInstaller command. This command however is not being recognized by the system (' No such file or directory' error is thrown) which to my opinion means one of two things: either command is misspelled in the manual or the command file that runs it is missing. I tried it with or without a dot and slash and in small case letters, nothing works.
    When I installed similar libraries on Linux I had no problems but all was required there was to place libraries in the proper directory, no command was required.
    Maybe same can be done here as well but I am not sure where to place some of the files. I see .h files that should go to /usr/include but see no .so files that on Linux go to /usr/lib. There are some files with .dylib and other .*lib extensions but I'm not sure if they should be copied to /usr/lib or not. And then there are some other files I have no idea what to do with.
    Please help!!!No, you can't just drop a few files into a directory and have a working installation (well, I guess technically you could. But technically you could bail all the water out of Lake Superior with a teacup ...)
    Sounds like you've covered PATH and current directory issues. What about permissions? What OS account are you using for this installation? (you should have created an account called "oracle" and made it's primary group "dba"). Does that account have execute permissions?
    >
    Thanks in advance!
    Edited by: user8744713 on Mar 26, 2010 10:17 AM

  • Please give me advice for my icloud situation.

    My nam is Luan, I am from Vietnam
    In November 2013, my dad - who is quite old - bought an iphone 5 in a mobile store located in district 10, Ho Chi Minh city. At that time, the shop's owner signed his Apple ID to this iphone. My dad, at that time, still did not know much about icloud. So he let the shop's owner sign in with the thought that if anything could happen, he just claimed the shop for this.
    And the problem is, one week ago, we had to restore our phone for some reasons. After that, we have been locked by icloud security. We came back to the shop and asked them which ID Apple they had used to sign in. They gave me about 3,4 accounts and told us that they did not remember which was the exact one. Then I tried them all and one account worked, but Apple told us that this account have been deativated for security. I came back to the shop again and asked them for the e-mail and password they used to create this Apple ID. And once again, they told us that e-mail has been hacked.
    My dad and me were too upset. We love Apple so much but lacking of supplemental knowledge ruins this beautiful mobile phone. I wonder if somebody and Apple could help me to unlock icloud.
    We are so grateful for that. Thank you very much.
    Luan Nguyen

    Have the shop owner contact the Apple account security team to try to get the ID enabled again, by calling the number for your country listed here: http://support.apple.com/kb/HT5699.  Or have the owner contact iTunes store support for assistance enabling the ID by send them an email here: https://ssl.apple.com/emea/support/itunes/contact.html.
    If the shop owner cannot fix this for you, you should return the phone for a refund.  They should not have sold you a phone that was linked to their Apple ID.

  • JTabbedPane question. Please give advice.

    I am writing some applicaiton which includes a jTabbedPane.(with 4 tabs)
    Say I have tab A,B,C,D. Which contains panelA, panelB, panelC and panelD under each tab.
    I would like to refresh corresponding panel when user click on the tab.
    I tried panelB's focusGained event, but it doesn't work right. I would have to click on some control of other panel for it to work.
    How do I trigger a function which user click on B tab? not some control in panelB.
    I am new to swing. please give some advice.
    Thanks

    Add a changeListener to your JTabbedPane which forwards an update to your panels when the current tab is changed,
    ... or ...
    put your updating in a overridden setVisible() in your panels, since the JTabbedPane uses visibility to control which tab gets shown.

  • I have downloaded DNG Profile Editor 1_0_4 and prepared a profile which I can not see in my Camera Raw 6.0 (I have photoshop CS5). Could you please give me an advice?

    I have downloaded DNG Profile Editor 1_0_4 and prepared a profile which I can not see in my Camera Raw 6.0 (I have photoshop CS5). Could you please give me an advice?

    Uninstall Trusteer software
    http://www.trusteer.com/support/uninstalling-rapport-mac-os-x
    Remove Sophos
    https://discussions.apple.com/message/21069437#21069437

  • I'm trying to downgrade my storage on my ipod but when I chose my new storage i'm not able to complete the choice because the 'done' button doesn't do anything. can someone please give me some advice?

    I'm trying to downgrade my storage on my ipod but when I chose my new storage i'm not able to complete the choice because the 'done' button doesn't do anything. can someone please give me some advice?

    Are you choosing a different plan before tapping Done?
    To downgrade, you should be doing the following:
    Go to Settings > iCloud > Storage & Backup.
    Tap Change Storage Plan.
    Tap Downgrade Options and enter your Apple ID password.
    Choose a different plan to use when your current storage plan expires.
    Tap Done.

  • I can not read any contents in my yahoo inbox messages? It is blank when i opened my message. Are there any setting or updated that i missed? Please give me some advices? Thank you. Phuong

    Question:
    I can not read any contents in my yahoo inbox messages? It is blank when i opened my message. Are there any setting or updated that i missed? Please give me some advices? Thank you. Phuong

    Hi AM_Kidd.
    Thanks for your reply.
    I have done a complete uninstall and re install of iTunes and all related apple programs from my laptop through control panel, add remove programs and also by going through program files and deleting all tracers of any left over folders remove programs may have missed.
    My apologies for forgetting to add this in my original post.
    Thanks again

  • I'm unable to download the German dictionary. I tried to do it with a 3g connection, but I failed because of that. Now I have a wi-fi connection, but I still can't download it. Could you give me advice please?

    I'm unable to download the German dictionary. I tried to do it with a 3g connection, but I failed because of that. A message said that I had to have a wi-fi connection to contine the download. Now I have a wi-fi connection, but I still can't download it. Could you give me advice please?

    I did activate the German keyboard, and I entered in the application "notes",in which I typed a german word with the german keyboard... But I can't get "define". It only appears to me when I select a word from an ebook, but when I ask for the definition of a German word there, it simply says "no definition found", as if the German dictionary didn't exist. I know that it exists... When I tried for the first time to get a definition for a German word, it appeared a writing which asked me if I wanted to download the German dictionary. I selected "yes", but I was connected to a 3g connection at the moment, so the ipad didn't download the dictionary, but another writing told me that the download would have continued when I was connected to a wi-fi. It didn't. And now I don't know how to continue the download. I've installed the French dictionary and the English one, but for the German one that's what happened. Maybe the ipads work differently in each country?

  • Urgent!!! please give me some advice

    i quite new in J2ME programming. i encountered a problem that my MIDlet cannot pass parameter to servlet. i had tried to not using os.flush(), but it's still not working. please give me some suggestion!
    MIDlet
    * Login.java
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.io.StreamConnection;
    import java.io.DataOutputStream;
    import java.io.DataInputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.IOException;
    import java.util.*;
    public class Login extends MIDlet implements CommandListener {
    Display display;
    boolean commandAvailable;
    // String idPassword;
    CommandThread commandThread;
    Form inputForm;
    Form outputForm;
    TextField userid;
    TextField password;
    StringItem response;
    Command cmdExit;
    Command cmdOK;
    public void startApp() {
    display = Display.getDisplay(this);
    inputForm = new Form("Authorization");
    userid = new TextField("User",null,25, TextField.ANY);
    inputForm.append(userid);
    password = new TextField("Password",null, 15, TextField.PASSWORD);
    inputForm.append(password);
    cmdOK = new Command("OK",Command.SCREEN,1);
    cmdExit = new Command("Exit",Command.EXIT,1);
    inputForm.addCommand(cmdOK);
    inputForm.addCommand(cmdExit);
    inputForm.setCommandListener(this);
    outputForm = new Form("Student Option");
    response = new StringItem(null,null);
    outputForm.append(response);
    outputForm.addCommand(cmdExit);
    outputForm.setCommandListener(this);
    commandAvailable = false;
    commandThread = new CommandThread(this);
    commandThread.start();
    display.setCurrent(inputForm);
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    public void commandAction(Command cmd, Displayable d) {
         if (cmd == cmdExit) {
    destroyApp(false);
    notifyDestroyed();
    else if (cmd == cmdOK)
    synchronized (this) {
    commandAvailable = true;
    notify();
    class CommandThread extends Thread {
    MIDlet parent;
    boolean exit = false;
    public CommandThread(MIDlet parent) {
    this.parent = parent;
    public void run() {
    while (true) {
    synchronized(parent) {
    while(!commandAvailable) {
    try {
    parent.wait();
    catch (InterruptedException e) {
    commandAvailable = false;
    performLogin();
    public void performLogin() {
    HttpConnection conn = null;
    InputStream is = null;
    OutputStream os = null;
    byte[] receivedData = null;
    try {
    String url = getAppProperty("Login.URL");
    conn = (HttpConnection)Connector.open(url);
         byte[] postData = createPostData();
    conn.setRequestMethod(HttpConnection.POST);
    conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
         conn.setRequestProperty ( "Content-Length", Integer.toString (postData.length));
    // conn.setRequestProperty("Accept", "application/octet-stream" );
    conn.setRequestProperty("Connection", "close" );
    // byte[] postData = createPostData();
    System.out.println("postData="+postData);
    conn.setRequestProperty("Content-length",Integer.toString(postData.length));
         os = conn.openOutputStream();
         os.write(postData);
    for (int i=0;i<postData.length;i++)
              os.write(postData);
    //     os.flush();
         os.close();
         is = conn.openInputStream();
         String contentType = conn.getType();
    int len = (int)conn.getLength();
    if (len > 0) {
    receivedData = new byte[len];
    int nb = is.read(receivedData);
    else {
    receivedData = new byte[1024];
    int ch;
    len = 0;
    while ((ch = is.read()) != -1) {
    receivedData[len++] = (byte)ch;
    response.setText(new String(receivedData,0,len));
    display.setCurrent(outputForm);
    catch (IOException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    finally {
    try {
    if (is != null) {
    is.close();
    if (os != null) {
    os.close();
    if (conn != null) {
    conn.close();
    catch (IOException e) {
    public byte[] createPostData() {
    StringBuffer sb = new StringBuffer();
    sb.append("userid=");
    sb.append(userid.getString());
    sb.append("&password=");
    sb.append(password.getString());
    System.out.println("sb = <" + sb.toString() + ">");
    return sb.toString().getBytes();
    servlet
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class LoginServlet extends HttpServlet {
    static final String dbURL = "jdbc:mysql://localhost/projectdb?" + "user=wongyuenmei&password=wongyuenmei";
    public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
    Connection conn = null;
    String nextJSP = null;
    try {
    Class.forName("org.gjt.mm.mysql.Driver");
    catch (ClassNotFoundException e) {
    throw new ServletException("Unable to load JDBC driver");
    try {
    String id = request.getParameter("userid").trim();
    String pass = request.getParameter("password").trim();
         if (id==null)
    String tempid=id;
    String temppass=pass;
    conn = DriverManager.getConnection(dbURL);
    Statement stmt = conn.createStatement();
    String query = "SELECT cno, idno " + "FROM student " + "WHERE idno = '" + id + "'AND password ='" + pass + "'";
    ResultSet rs = stmt.executeQuery(query);
    if (rs.next()) {
    StringBuffer fullName = new StringBuffer();
    fullName.append(rs.getString(1));
    fullName.append(" ");
    fullName.append(rs.getString(2));
    request.setAttribute ("fullName", fullName.toString());
    nextJSP = "/LoginOK.jsp";
    else {
         StringBuffer temptest = new StringBuffer();
         temptest.append(tempid);
         temptest.append(&temppass);
         request.setAttribute("temptest", temptest.toString());
    nextJSP = "/LoginFailed.jsp";
    conn.close();
    ServletConfig config = getServletConfig();
    ServletContext context = config.getServletContext();
    RequestDispatcher rd = context.getRequestDispatcher(nextJSP);
    rd.forward(request, response);
    catch (SQLException e) {
    throw new ServletException("SQL call failed");
    catch (Exception e) {
    throw new ServletException(e.getMessage());
    finally {
    if (conn != null) {
    try {
    conn.close();
    catch (SQLException e) {
    throw new ServletException("connection close failed");
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    doPost(request, response);
    ur help is very appreciated!

    Still the same problem. All the parameter get by server are null.
    Using GET, and add parameter to url, everything is fine.
    encodedPostData = "E2EE_PAM_ID"+"="+E2EE_PAM_ID+"&"+"E2EE_USER_ID"+"=" E2EE_USER_ID"&"+"E2EE_USER_SEGUID"+"="+E2EE_USER_SEGUID+"&"+"E2EE_RPIN"+"="+E2EE_RPIN
    +"&LoginBtn=Login";
    c = (HttpConnection)Connector.open(request);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
    c.setRequestProperty("Content-Type:","application/x-www-form-urlencoded");
    os = c.openOutputStream();
    os.write(encodedPostData.getBytes());
    //os.flush();
    System.out.println(encodedPostData);
    rc = c.getResponseCode();
    if (rc != HttpConnection.HTTP_OK) {
    throw new IOException("HTTP response code: " + rc);
    is = c.openInputStream();
    ..........

Maybe you are looking for