Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

rus1ko1983
Copy link
Collaborator

No description provided.

@rus1ko1983 rus1ko1983 changed the title Jg 92 homework6 ruslan modify file JG 92 homework6 ruslan modify file Nov 30, 2018
@rus1ko1983
Copy link
Collaborator Author

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";
Copy link
Owner

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){
Copy link
Owner

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

@rus1ko1983 rus1ko1983 changed the title JG 92 homework6 ruslan modify file JG 91 homework6 ruslan modify file Dec 3, 2018
@rus1ko1983 rus1ko1983 changed the title JG 91 homework6 ruslan modify file JG 92 homework6 ruslan modify file Dec 17, 2018
@rus1ko1983 rus1ko1983 changed the title JG 92 homework6 ruslan modify file JG 91 homework6 ruslan modify file Dec 17, 2018

BufferedWriter writer = new BufferedWriter(new FileWriter(new File(FILENAME)));
writer.append(str);
writer.close();
Copy link
Owner

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);
Copy link
Owner

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));
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants