The main international law governing refugees is the 1951 Refugee Convention. The majority of the nations in the world have signed this treaty (and/or its 1967 Protocol); notable exceptions include most of the Middle East, and most of South and Southeast Asia. (As to your example, Japan has signed it.)
The full text of the treaty can be found at the website of the UN High Commission for Refugees. I think most of your questions can be addressed by reading it, but in particular, we have the following excerpts from Articles 32-34:
The Contracting States shall not impose penalties, on account of their
illegal entry or presence, on refugees who, coming directly from a territory
where their life or freedom was threatened in the sense of article 1, enter or
are present in their territory without authorization, provided they present
themselves without delay to the authorities and show good cause for their
illegal entry or presence. [...]
The Contracting States shall not expel a refugee lawfully in their territory save on grounds of national security or public order.
[...]
The Contracting States shall as far as possible facilitate the assimilation and
naturalization of refugees. They shall in particular make every effort to expedite naturalization proceedings and to reduce as far as possible the charges
and costs of such proceedings.
So very generally speaking, if you were to flee from this hypothetical Second Korean War and end up in Japan, then Japan would be obligated under the 1951 Convention to take you in, provide for you in a manner comparable to its own citizens, and give you an opportunity to eventually become a Japanese citizen.
Of course, this has various limitations and caveats. For instance, they could investigate (via legal proceedings) whether you really were a refugee under the definition of the 1951 Convention; and they could expel you if you had committed a serious crime or posed a risk to national security.