DSP tutorial: Hello world
Last modified: November 16th, 2011This simple example prints a line to the console, writes a line to a text file, reads it back and displays it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | public class HelloWorld { public static void main(String[] args) { String hello = "Hello world!"; hello = hello + " oh!"; System.out.println(hello); // writing a line to a text file try { BufferedWriter outputStream = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("hello.txt"),"UTF-8")); outputStream.write("űáéúőéú"); outputStream.write(10); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } // reading and displaying a line from a text file BufferedReader inputStream; try { inputStream = new BufferedReader(new InputStreamReader(new FileInputStream("hello.txt"), "UTF-8")); System.out.println(inputStream.readLine()); inputStream.close(); } catch (Exception e) { e.printStackTrace(); } } } |
download (3.7 kb)
Compiling
Download Eclipse for Java, then extract it to your Program Files folder, and launch it. I think Eclipse is the best SDK for Java development.
Open the Hello World app in Eclipse and run it. Note: there’s a precompiled .jar file included in all tutorials. You can run .jar files by using this command line: java.exe -jar pack.jar
About me
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with.
... »
Trackback URL
No comments yet.
Trackback responses to this post