Java File Write fileWriter(int startpt, int letter)

Here you can find the source of fileWriter(int startpt, int letter)

Description

file Writer

License

Open Source License

Declaration

public static void fileWriter(int startpt, int letter) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.PrintWriter;
import java.util.ArrayList;

public class Main {
    public static void fileWriter(int startpt, int letter) {
        System.out.println("Start point: " + (char) startpt);
        System.out.println("End point: " + (char) 55203);
        String filename = (char) letter + "";
        System.out.println("Writing to file: " + filename);
        ArrayList letters = lastLetterGen(startpt);
        try {//from   www  .jav a  2 s  .  co  m
            PrintWriter pr = new PrintWriter(filename);

            for (int i = 0; i < letters.size(); i++) {
                pr.println(letters.get(i));
            }
            pr.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("No such file exists.");
        }
    }

    public static ArrayList<Character> lastLetterGen(int StartPoint) {
        int EndPoint = 55203;
        ArrayList<Character> blocks = new ArrayList<>();
        blocks.add((char) StartPoint);
        int i = StartPoint;
        while (i < EndPoint) {
            i += 6;
            blocks.add((char) i);
            i += 22;
            blocks.add((char) i);
        }
        return blocks;
    }
}

Related

  1. fileWrite(String filePath, String data)
  2. fileWrite(String filePath, String fileName, String content)
  3. fileWrite(String path, int format, String content, Object bytesObj)
  4. fileWrite(String[] text, File file)
  5. fileWriteOut(InputStream in, String outPath)
  6. fileWriter(String outfile, String contents, boolean append)
  7. fileWriteString(String filePath, String strWrite, boolean append)