A hardship withdrawal can be taken from a 401K plan in certain situations. Under most circumstances it is not advised to withdraw funds from an IRA or 401K account prior to retirement. You will be subjected to income tax on the withdrawals at both the federal and likely state and local levels, as well as a 10% penalty tax if the withdrawal is taken prior to age 59 1/2 (unless you meet certain exceptions). Perhaps more importantly, a withdrawal prior to retirement will have the effect of depleting your retirement savings as well as the future earnings on these savings.
In the case of a hardship withdrawal, you will need to meet certain requirements related to your hardship. You will be unable to make contributions to the plan for a period of six months subsequent to the hardship withdrawal. If your employer makes matching contributions to the plan, these will be suspended as well.