DSP tutorial: Hello world

This 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 (mirror2) (3.7 kb, 28 dls, today: 0)

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

Name (required)
E-mail (required - never shown publicly)
Webpage URL
Comment:
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> in your comment.

Trackback responses to this post

About me

Nonoo
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with. ... »

Twitter

Listening now

My favorite artists