Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,19 @@ public synchronized void setFile(File f) {
public synchronized File getFile() {
return file;
}

public String getContent() throws IOException {
FileInputStream i = new FileInputStream(file);
String output = "";
int data;
while ((data = i.read()) > 0) {
output += (char) data;
}
return output;
Scanner scanner = new Scanner(file);
String content = scanner.useDelimiter("\\A").next();
scanner.close();
return content;
}

public String getContentWithoutUnicode() throws IOException {
FileInputStream i = new FileInputStream(file);
String output = "";
int data;
while ((data = i.read()) > 0) {
if (data < 0x80) {
output += (char) data;
}
}
return output;
return getContent().replaceAll("[\\p{Cc}\\p{Cf}\\p{Co}\\p{Cn}]", "");
}

public void saveContent(String content) throws IOException {
FileOutputStream o = new FileOutputStream(file);
for (int i = 0; i < content.length(); i += 1) {
o.write(content.charAt(i));
}
new PrintStream(new FileOutputStream(file)).print(content);
}
}
}