-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JG 91 homework6 ruslan modify file #88
base: master
Are you sure you want to change the base?
Conversation
Hi, Please check |
// URL resource = ReadInBUFTest.class.getClassLoader().getResource("Text.txt"); | ||
// System.out.println(resource); | ||
// String fileFrom = resource.getFile(); | ||
String fileFrom = "/home/rstepanc/IdeaProjects/java-geeks/modules/ruslan/target/classes/Test"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not be absolute path here
writer.close(); | ||
} | ||
|
||
public static byte[] toLow(byte[] arr){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be made with regex not array of bytes
|
||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(FILENAME))); | ||
writer.append(str); | ||
writer.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close should always be called in finally block
|
||
//given | ||
URL resource = ReadInBUFTest.class.getClassLoader().getResource("Test"); | ||
System.out.println(resource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need System.out.println(resource);
|
||
public static void WorkWithFile (File file) throws IOException { | ||
|
||
BufferedReader br = new BufferedReader(new FileReader(file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use try catch with resources, or just try block, and close streams
No description provided.