Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String tempString = "";
- String tempStringTwo = "";
- String [] convertedLines = new String [100];
- int counter = 0;
- int tempcount = 0;
- File file = new File("input.txt");
- if (!file.exists()) {
- System.out.println(args[0] + " does not exist.");
- return;
- }
- if (!(file.isFile() && file.canRead())) {
- System.out.println(file.getName() + " cannot be read from.");
- return;
- }
- try {
- FileInputStream fis = new FileInputStream(file);
- char current;
- while (fis.available() > 0) { // Filesystem still available to read bytes from file
- current = (char) fis.read();
- tempString = tempString + current;
- int character = (int) current;
- if (character==13) { // found a line break in the file, need to ignore it.
- //tempString = tempString.replace("n"," ").replace("r"," ");
- tempString = tempString.replaceAll("\r|\n", " ");
- //tempString = tempString.substring(0,tempString.length()-1);
- //System.out.println(tempString);
- }
- if (character==46) { // found a period
- //System.out.println("Found a period.");
- convertedLines[counter] = tempString;
- tempString = "";
- counter++;
- tempcount = counter;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- System.out.println("------------------------------------------------");
- for (int z=0;z<tempcount;z++){
- System.out.println(convertedLines[z]);
- }
- }
- Here's my current output...
- ------------------------------------------------
- The quick brown fox
- jumps over the lazy dogs.
- Now is the time for all good men to come to the
- aid of their country.
- All your base are
- belong to us.
- Here's what I need...
- -----------------------------------------------------
- The quick brown fox jumps over the lazy dogs.
- Now is the time for all good men to come to the aid of their country.
- All your base are belong to us.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement