achmad irfan
achmad irfan

Reputation: 55

How make line breaks with \n in strings in Android (input from linux)

I have a problem when i click button 'list domain' on my android, in linux(server) will excute the command

cat /var/listdomain.txt

and linux will give an output

irfan.com
jarkom.com
you.co.id

but an output on my android is like this

irfan.comjarkom.comyou.co.id

what should i do to on my android output

irfan.com
jarkom.com
you.co.id

This is my syntax in eclips

public final Button.OnClickListener bLihatIsi = new Button.OnClickListener() {
     @Override
    public void onClick(View v) {
        try {
        AlertDialog.Builder dialog = new AlertDialog.Builder(actual);
                    dialog.setTitle(getResources().getString(R.string.execute)
                            + getResources().getString(R.string.Terminal)
                            + " ?");
                    dialog.setMessage(getResources().getString(
                            R.string.popLihat)
                            + " ?");
                    dialog.setNegativeButton(getResources().getString(
                            R.string.no),
                            new DialogInterface.OnClickListener() {
    @Override
public void onClick(
        DialogInterface dialogInterface, int i) {
        }
                            });
            dialog.setPositiveButton(getResources().getString(
        R.string.yes),
        new DialogInterface.OnClickListener() {
        @Override
        public void onClick(
        DialogInterface dialogInterface, int i) {
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
        Server server = serverlist.get(spinner.getSelectedItemPosition() - 1);
        if (server != null ){
                final String LIHATISI = "cat /var/listdomain.txt";

                DnsConnect u = new DnsConnect();
                Command c = new Command (getResources().getText(R.string.konfdnsdel).toString(), LIHATISI, server);
                                    u.setCommand(LIHATISI);

    pd = ProgressDialog.show(actual, getResources().
        getString(R.string.PleaseWait), c.getName());
        actualThreadCommand = c;
        Thread thread = new Thread(actual);
        thread.start();

        } else {
                                    Toast.makeText(getBaseContext(),
                                            getResources().getText(R.string.tabelkosongkonten),
                                            Toast.LENGTH_LONG).show();
        }

    }
    });
dialog.show();

Upvotes: 2

Views: 288

Answers (1)

http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html

String lineSep=System.getProperty("line.separator");

you can use this in place of "\n" to break the line.

Upvotes: 2

Related Questions