Skip to content

Instantly share code, notes, and snippets.

@mehmetbebek
Last active August 29, 2015 14:07
Show Gist options
  • Save mehmetbebek/12f45dac2bec873e6ff9 to your computer and use it in GitHub Desktop.
Save mehmetbebek/12f45dac2bec873e6ff9 to your computer and use it in GitHub Desktop.
Bir Kelime Bir İşlem
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Main {
static List<String> foundStrings = new ArrayList<String>();
private static boolean searchFlag = false;
public static void main(String[] args) throws IOException {
String enteredString = "mehmet";
if (searchFlag) {
searchInList();
} else {
searchInFile();
}
}
private static void searchInFile() throws IOException,
FileNotFoundException {
File dir = new File(".");
File fin = new File(dir.getCanonicalPath() + File.separator + "src"
+ File.separator + "full.txt.tr");
try (BufferedReader br = new BufferedReader(new FileReader(fin))) {
for (String line; (line = br.readLine()) != null;) {
char characters[] = new char[] { 't', 'm', 'v', 'h', 'u', 'e' };
// String x = null;
int flag = 0;
for (char c : characters) {
int result = line.toLowerCase().indexOf(c);
if (result < 0) {
flag = 0;
break;
} else {
flag = 1;
}
}
if (flag == 1) {
System.out.println(line);
foundStrings.add(line);
}
}
}
}
private static void searchInList() {
if (foundStrings.size() == 0) {
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment