import java.io.*;
public class FindFile1 {
 public static void main (String args) {
  if (args.length != 2) {
  System.out.println("使用例:java FindFile1 検索文字列 検索対象ファイル");
  System.out.println("例:java FindFile1 System FindFile1.java");
  System.exit(0);
 }
 String findstring = args[0];
 String filename = args[1];
 try {
  String line;
  int linenum = 1;
  BufferedReader reader = new BufferedReader(new FileReader(filename));
  while ((line = reader.readLine()) != null) {
   int n = line.indexOf(findstring);
   if (n >= 0) {
   System.out.println(linenum + ":" + line);
   }
   linenum++;
  }
  reader.close();
 }catch (FileNotFoundException e) {
  System.out.println(filename + "が見つかりません。");
 }catch (IOException e) {
  System.out.println(e);
  }
 }
}
 
 
 
 
 
 
 
 
 
 
 
import java.io.*;
public class Prime1 {
 static int MAX_PRIME = 1000;
 public static void main (String args) {
  if (args.length != 1) {
  System.out.println("使用法:java Prime1 作成ファイル");
  System.out.println("例:java Prime1 prime.txt");
  System.exit(0);
  }
  String filename = args[0];
  try {
   PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
   writePrime(writer);
   writer.close();
  } catch (IOException e) {
   System.out.println(e);
  }
 }
 public static void writePrime(PrintWriter writer) {
  boolean[] prime = new boolean[MAX_PRIME];
  for (int n = 0; n < MAX_PRIME; n++) {
   prime[n] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for (int n = 0; n < MAX_PRIME; n++) {
   if (prime[n]) {
    writer.println(n);
    for (int i = 2; i * n < MAX_PRIME; i++) {
     prime[i * n] = false;
    }
       }
  }
     }
}