473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

What Does This Mean ????

lifeisgreat20009
This is what i am getting on running the program.........

C:\PROGRA~1\Java\JDK15~1.0\bin>javac Editor.java
Note: Editor.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.


Below is my code with no errors but its not running.........


Expand|Select|Wrap|Line Numbers
  1.  import java.awt.*;
  2. import java.awt.event.*;
  3. import java.io.*;
  4.  
  5. class Editor extends Frame implements ActionListener
  6. {
  7. TextArea textArea = new TextArea();
  8.  
  9. //Set up the menu on the default CTOR.
  10. Editor()
  11. {
  12. super("Text AWT Editor");
  13. setLayout(new BorderLayout());
  14. add("Center", textArea);
  15. Menu menu = new Menu("File");
  16. menu.add(makeMenuItem("Open"));
  17. menu.add(makeMenuItem("Save"));
  18. menu.add(makeMenuItem("Quit"));
  19. MenuBar menuBar = new MenuBar();
  20. menuBar.add(menu);
  21. setMenuBar(menuBar);
  22. pack();
  23. }
  24. private MenuItem makeMenuItem(String name)
  25. {
  26. MenuItem m = new MenuItem(name);
  27. m.addActionListener(this);
  28. return m;
  29. }
  30. public static void main(String[] s)
  31. {
  32. new Editor().show();
  33. }
  34. public void actionPerformed(ActionEvent e)
  35. {
  36. String command = e.getActionCommand();
  37. if (command.equals("Quit"))
  38. dispose();
  39. else if (command.equals("Open"))
  40. openFile();
  41. else if (command.equals("Save"))
  42. saveFile();
  43. }
  44. private void openFile()
  45. {
  46. //Show the Open File dialog box to the user.
  47. FileDialog fd = new FileDialog(this, "Open File", FileDialog.LOAD);
  48. fd.show();
  49.  
  50. //Get the file path.
  51. StringBuffer sbPath = new StringBuffer(fd.getDirectory());
  52. sbPath.append("\\");
  53. String fileName = fd.getFile();
  54.  
  55. //Cancel if null:
  56. if (fileName == null)
  57. {
  58. return;
  59. }
  60. else sbPath.append(fileName);
  61.  
  62. // Open and fill the input stream; paint the TextArea.
  63. try
  64. {
  65. FileInputStream fs = new FileInputStream(sbPath.ToString());
  66. byte[] data = new byte [ sbPath.length() ];
  67. fs.read(data);
  68. textArea.setText(new String(data));
  69. }
  70. catch (IOException e)
  71. {
  72. textArea.setText(e.toString());
  73. }
  74. }
  75.  
  76. private void saveFile()
  77. {
  78. try
  79. {
  80. // Show the dialog box to the user.
  81. FileDialog fd = new FileDialog(this, "Save File", FileDialog.SAVE);
  82. fd.show();
  83.  
  84. //Get the path and file name.
  85. StringBuffer sbPath = new StringBuffer(fd.getDirectory());
  86. sbPath.append("\\");
  87. // Get the file name to create:
  88. sbPath.append(fd.getFile());
  89. FileOutputStream fo = new FileOutputStream(sbPath.ToString());
  90.  
  91. // Parse the data: 
  92. String strdata = textArea.getText();
  93. byte[] data = new byte [strdata.length()];
  94. for (int idx = 0; idx < strdata.length(); idx++)
  95. {
  96. data[idx] = (byte)strdata.charAt(idx);
  97. }
  98. // Write the array to the file.
  99. fo.write(data);
  100. }
  101. catch (IOException ex)
  102. {
  103. textArea.setText(ex.toString());
  104. }
  105. }
  106. }
Nov 1 '07 #1
1 3836
r035198x
13,262 8TB
Below is the code of my Java Editor........
Plzzzzzz help me remove the 2 errors........
I would be very grateful.........................


import java.awt.*;
import java.awt.event.*;
import java.io.*;

class Editor extends Frame implements ActionListener
{
TextArea textArea = new TextArea();

//Set up the menu on the default CTOR.
Editor()
{
super("Text AWT Editor");
setLayout(new BorderLayout());
add("Center", textArea);
Menu menu = new Menu("File");
menu.add(makeMenuItem("Open"));
menu.add(makeMenuItem("Save"));
menu.add(makeMenuItem("Quit"));
MenuBar menuBar = new MenuBar();
menuBar.add(menu);
setMenuBar(menuBar);
pack();
}
private MenuItem makeMenuItem(String name)
{
MenuItem m = new MenuItem(name);
m.addActionListener(this);
return m;
}
public static void main(String[] s)
{
new Editor().show();
}
public void actionPerformed(ActionEvent e)
{
String command = e.getActionCommand();
if (command.equals("Quit"))
dispose();
else if (command.equals("Open"))
openFile();
else if (command.equals("Save"))
saveFile();
}
private void openFile()
{
//Show the Open File dialog box to the user.
FileDialog fd = new FileDialog(this, "Open File", FileDialog.LOAD);
fd.show();

//Get the file path.
StringBuffer sbPath = new StringBuffer(fd.getDirectory());
sbPath.append("\\");
String fileName = fd.getFile();

//Cancel if null:
if (fileName == null)
{
return;
}
else sbPath.append(fileName);

// Open and fill the input stream; paint the TextArea.
try
{
FileInputStream fs = new FileInputStream(sbPath.ToString());
byte[] data = new byte [ sbPath.length() ];
fs.read(data);
textArea.setText(new String(data));
}
catch (IOException e)
{
textArea.setText(e.toString());
}
}

private void saveFile()
{
try
{
// Show the dialog box to the user.
FileDialog fd = new FileDialog(this, "Save File", FileDialog.SAVE);
fd.show();

//Get the path and file name.
StringBuffer sbPath = new StringBuffer(fd.getDirectory());
sbPath.append("\\");
// Get the file name to create:
sbPath.append(fd.getFile());
FileOutputStream fo = new FileOutputStream(sbPath.ToString());

// Parse the data:
String strdata = textArea.getText();
byte[] data = new byte [strdata.length()];
for (int idx = 0; idx < strdata.length(); idx++)
{
data[idx] = (byte)strdata.charAt(idx);
}
// Write the array to the file.
fo.write(data);
}
catch (IOException ex)
{
textArea.setText(ex.toString());
}
}
}


The following are the 2 errors......


C:\Program Files\Java\jdk1.5.0\bin>javac editor.java
editor.java:65: cannot find symbol
symbol : method ToString()
location: class java.lang.StringBuffer
FileInputStream fs = new FileInputStream(sbPath.ToString());
^
editor.java:89: cannot find symbol
symbol : method ToString()
location: class java.lang.StringBuffer
FileOutputStream fo = new FileOutputStream(sbPath.ToString());
^
Note: editor.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors



Pleaseeeeeeee help me remove the errors........
1.) Use code tags when posting code
2.) Use meaningful thread titles that best decribe your problem
3.) Java is case sensitive so ToString is not the same as toString
Nov 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
2
by: Steve Richter | last post by:
What does the "." mean in the following sql script stmts? use GO if exists (select * from dbo.sysobjects where id = object_id(N'.') and OBJECTPROPERTY(id,N'IsUserTable') = 1) drop table ....
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
1
by: Frank Rizzo | last post by:
Some of the classes in the framework are marked as thread-safe in the documentation. In particular the docs say the following: "Any public static (*Shared* in Visual Basic) members of this type...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.