Skip to content

Instantly share code, notes, and snippets.

@AlphaFactory
Last active December 28, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlphaFactory/7464305 to your computer and use it in GitHub Desktop.
Save AlphaFactory/7464305 to your computer and use it in GitHub Desktop.
Java Paragraph
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class start
{
public static void main(String[] args)
{
ArrayList<String> lines = new ArrayList<String>();
try
{
BufferedReader in = new BufferedReader(new FileReader(args[0]));
String s;
StringBuilder sb = new StringBuilder();
while ((s = in.readLine()) != null)
{
sb.append(s + "\n");
}
in.close();
String pattern = "([^\\.]+)\\n";
//"(\\.|」|\")(\\s){1,}\n";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(sb);
while (m.find())
{
m.replaceAll("$1");
}
System.out.println(sb.toString());
} catch (IOException e)
{
System.err.println(e);
System.exit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment