Java Wrieless Toolkit

Ads

 
 

Share on Google+Share on Google+

aygun
Java Wrieless Toolkit
2 Answer(s)      6 years and 7 months ago
Posted in : Java Beginners

MY application code does not work on the Java Wireless Toolkit-

import java.io.*;

public Write{

public static void main(String[] args) throws IOException{

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

System.out.print("Please enter the file name to create : ");

String file_name = in.readLine();


File file = new File(file_name);

boolean exist = file.createNewFile();

if (!exist)

{
  System.out.println("File already exists.");

  System.exit(0);

}
else
{

  FileWriter fstream = new FileWriter(file_name);

  BufferedWriter out = new BufferedWriter(fstream);

  out.write(in.readLine());

  out.close();

  System.out.println("File created successfully.");
}

} } this indicates error :::::::->

Project "Numune7" loaded

Project settings saved

Building "Numune7"

C:\WTK23\apps\Numune7\src\Write.java:3: class or interface expected

public Write{

   ^

C:\WTK23\apps\Numune7\src\Write.java:5: class or interface expected

public static void main(String[] args) throws IOException{

            ^

C:\WTK23\apps\Numune7\src\Write.java:7: class or interface expected

System.out.print("Please enter the file name to create : ");

^

C:\WTK23\apps\Numune7\src\Write.java:8: class or interface expected

String file_name = in.readLine();
^

C:\WTK23\apps\Numune7\src\Write.java:9: class or interface expected

File file = new File(file_name);
^

C:\WTK23\apps\Numune7\src\Write.java:10: class or interface expected

boolean exist = file.createNewFile();
^

C:\WTK23\apps\Numune7\src\Write.java:11: class or interface expected

if (!exist)
^

C:\WTK23\apps\Numune7\src\Write.java:14: class or interface expected System.exit(0);

  ^

C:\WTK23\apps\Numune7\src\Write.java:15: class or interface expected

}
^

C:\WTK23\apps\Numune7\src\Write.java:19: class or interface expected

  BufferedWriter out = new BufferedWriter(fstream);

  ^

C:\WTK23\apps\Numune7\src\Write.java:20: class or interface expected

  out.write(in.readLine());
  ^

C:\WTK23\apps\Numune7\src\Write.java:21: class or interface expected out.close();

  ^

C:\WTK23\apps\Numune7\src\Write.java:22: class or interface expected

  System.out.println("File created successfully.");
  ^

C:\WTK23\apps\Numune7\src\Write.java:23: class or interface expected } ^ 14 errors com.sun.kvem.ktools.ExecutionException

Build failed Running with storage root DefaultColorPhone

Running with locale: Russian_Russia.1251

Unable to create MIDlet Write

java.lang.ClassNotFoundException: Write

at com.sun.midp.midlet.MIDletState.createMIDlet(+29)

at com.sun.midp.midlet.Selector.run(+22)

Execution completed.

918411 bytecodes executed

30 thread switches

893 classes in the system (including system classes)

4528 dynamic objects allocated (127500 bytes)

1 garbage collections (0 bytes collected)

Ads
View Answers

March 10, 2011 at 5:01 PM


Try this:

import java.io.*;
public  class Write{
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter the file name to create : ");
String file_name = in.readLine();
File file = new File(file_name);
boolean exist = file.createNewFile();
if (!exist){
  System.out.println("File already exists.");
  System.exit(0);
}
else{
  FileWriter fstream = new FileWriter(file_name);
  BufferedWriter out = new BufferedWriter(fstream);
  out.write(in.readLine());
  out.close();
  System.out.println("File created successfully.");
}
}
}

Thanks



March 11, 2011 at 1:14 AM


<p>Thank you very much, but it did not help me. I am writing software code in the Java Wireless toolbar 2.3 beta. For this purpose, the expansion of the java file open. After I added you provide the program code into the file . Put this file in src directory. I do not think I am correct in this series? what I wrong? .. This should be a help to me</p>

<p>Project settings saved</p>

<p>Building "India"</p>

<p>C:\WTK23\apps\India\src\Write.java:6: cannot resolve symbol
symbol  : class BufferedReader </p>

<p>location: class Write
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
^
C:\WTK23\apps\India\src\Write.java:6: cannot resolve symbol
symbol  : class BufferedReader 
location: class Write
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                        ^
C:\WTK23\apps\India\src\Write.java:6: cannot resolve symbol
symbol  : variable in </p>

<p>location: class java.lang.System</p>

<p>BufferedReader in = new BufferedReader(new </p>

<p>InputStreamReader(System.in));
                                                                   ^
C:\WTK23\apps\India\src\Write.java:9: cannot resolve symbol
symbol  : class File 
location: class Write
File file = new File(file_name);
^
C:\WTK23\apps\India\src\Write.java:9: cannot resolve symbol
symbol  : class File </p>

<p>location: class Write</p>

<p>File file = new File(file_name);</p>

<pre class="prettyprint">            ^
</code></pre>

<p>C:\WTK23\apps\India\src\Write.java:16: cannot resolve symbol
symbol  : class FileWriter </p>

<p>location: class Write
  FileWriter fstream = new FileWriter(file_name);</p>

<p>  ^
C:\WTK23\apps\India\src\Write.java:16: cannot resolve symbol
symbol  : class FileWriter </p>

<p>location: class Write
  FileWriter fstream = new FileWriter(file_name);
                           ^
C:\WTK23\apps\India\src\Write.java:17: cannot resolve symbol
symbol  : class BufferedWriter 
location: class Write
  BufferedWriter out = new BufferedWriter(fstream);
  ^
C:\WTK23\apps\India\src\Write.java:17: cannot resolve symbol
symbol  : class BufferedWriter 
location: class Write</p>

<p>  BufferedWriter out = new BufferedWriter(fstream);
                           ^
9 errors
com.sun.kvem.ktools.ExecutionException
Build failed</p>

<p>Running with storage root DefaultColorPhone</p>

<p>Running with locale: Russian_Russia.1251</p>

<p>Unable to create MIDlet Write
java.lang.ClassNotFoundException: Write</p>

<pre class="prettyprint">at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Selector.run(+22)
</code></pre>

<p>Execution completed.</p>

<p>917006 bytecodes executed</p>

<p>27 thread switches</p>

<p>893 classes in the system (including system classes)</p>

<p>4520 dynamic objects allocated (127232 bytes)</p>

<p>1 garbage collections (0 bytes collected)</p>

Ads









Related Tutorials/Questions & Answers:
Java Wrieless Toolkit
Java Wrieless Toolkit  MY application code does not work on the Java Wireless Toolkit- import java.io.*; public Write{ public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new
java Toolkit
java Toolkit  how to set jframe form screen size any resolutions fit to full screen
Advertisements
Toolkit Class.......... - Java Beginners
Toolkit Class  Hi will you please tell me something about Toolkit class. What following code will give ToolKit kit=ToolKit.getDefaultToolKit(); Dimension dim=kit.getScreenSize(); & How JFileChosser is used Please
Version of com.onelogin>java-saml-toolkit dependency
List of Version of com.onelogin>java-saml-toolkit dependency
Sun Java Wireless Toolkit
Sun Java Wireless Toolkit       Java Platform, Micro Edition The Sun Java Wireless Toolkit is also known as Java Platform, Micro Edition (Java ME) Wireless Toolkit. Java
Maven Dependency java-saml-toolkit >> 2.0.0
You should include the dependency code given in this page to add Maven Dependency of com.onelogin >> java-saml-toolkit version2.0.0 in your project
Maven Dependency java-saml-toolkit >> 2.0.1
You should include the dependency code given in this page to add Maven Dependency of com.onelogin >> java-saml-toolkit version2.0.1 in your project
IT Mill Toolkit
IT Mill Toolkit       IT Mill Toolkit 5 is a server-side RIA framework that provides Java programmers with complete set of RIA widgets. Applications are programmed (with Java
What is the best in Ajax Toolkit?
What is the best in Ajax Toolkit?  What is the best in Ajax Toolkit? Is not Ajax toolkit similar to the Ajax control toolkit? Can you expand it? (Sr, I am not good at English
Plex Toolkit
Plex Toolkit       The Plex Toolkit is a collection of JavaScript libraries which handle the transformation of custom XML markup embedded in an HTML document into user interface
Version of com.airnauts>toolkit dependency
List of Version of com.airnauts>toolkit dependency
Google Web Toolkit
Google Web Toolkit       Google Web Toolkit (GWT) is a Java software development framework that makes... serializable Java classes for your request and response. In production, GWT
Version of com.dangdang>config-toolkit dependency
List of Version of com.dangdang>config-toolkit dependency
Version of com.thesett>junit-toolkit dependency
List of Version of com.thesett>junit-toolkit dependency
Maven Dependency toolkit >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.0.0 in your project
Maven Dependency toolkit >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.1.0 in your project
Maven Dependency toolkit >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.1.1 in your project
Maven Dependency toolkit >> 1.2.0
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.2.0 in your project
Maven Dependency toolkit >> 1.3.0
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.3.0 in your project
Maven Dependency toolkit >> 1.4.0
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.4.0 in your project
Maven Dependency toolkit >> 1.4.1
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.4.1 in your project
Maven Dependency toolkit >> 1.4.2
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.4.2 in your project
Maven Dependency toolkit >> 1.4.3
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version1.4.3 in your project
Maven Dependency toolkit >> 2.0.0
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version2.0.0 in your project
Maven Dependency toolkit >> 2.0.1
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version2.0.1 in your project
Maven Dependency toolkit >> 2.0.2
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version2.0.2 in your project
Maven Dependency toolkit >> 2.0.3
You should include the dependency code given in this page to add Maven Dependency of com.airnauts >> toolkit version2.0.3 in your project
Dojo Toolkit
Dojo Toolkit       Dojo is the Open Source JavaScript toolkit that helps you build serious applications in less time. It fills in the gaps where JavaScript and browsers don't go quite
Version of com.dangdang>config-toolkit-parent dependency
List of Version of com.dangdang>config-toolkit-parent dependency
Version of com.mozu>mozu-api-toolkit dependency
List of Version of com.mozu>mozu-api-toolkit dependency

Ads

 
Advertisement null

Ads