Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.BufferedWriter;

import java.io.File;

import java.io.IOException;

import java.io.OutputStreamWriter;

import android.content.Context;

public class Main {
    private final static String eol = System.getProperty("line.separator");
    final public static String userInfoPath = "companyinfo.txt";
    public static String[] userInfo;
    final private static String separator = "!@#$%^&*()_+";

    public static void writeUserInfo(String[] info, Context c) throws IOException {
        File f = c.getFileStreamPath(userInfoPath);
        if (!f.exists()) {
            f.createNewFile();
        }

        String output = "";
        for (int n = 0; n < info.length; n++) {
            output += info[n] + eol + separator + eol;
        }
        BufferedWriter out = null;
        out = new BufferedWriter(new OutputStreamWriter(c.openFileOutput(userInfoPath, Context.MODE_PRIVATE)));

        out.write(output);
        out.flush();
        out.close();
        userInfo = info;
    }
}