This can be solved by flag that you set in case you match your specific conditions:
java_regex = re.compile(...) # java
at_regex = re.compile(...) # at
copy = False # flag that control to copy or to not copy to output
for line in file_in:
if re.search(java_regex, line):
# start copying if "java" is in the input
copy = True
else:
if copy and not re.search(at_regex, line):
# stop copying if "at" is not in the input
copy = False
if copy:
file_out.write(line)