Possible threats
First of all we should consider what threats may apply:
Potential Threats to Hikers from Wild Pigs wild boar with sharp tusks
Feral pigs can exhibit aggressive territorial behaviors.
Hogs may weigh up to 300 pounds or more, can charge at least 11 mph and can quickly attack hikers.
Boars have four extremely sharp tusks up to five inches long that can severely injure or kill a hiker.
Hikers can contract disease (undulant fever, etc) from any contact with an infected hog.
Pigs can contaminate water sources with their feces.
I think it's especially interesting that a boar can harm you more than just with its direct physical charges.

How an attack looks like
Friends of the boar have summarized how an encounter might look like from the beginning. I want to show of the warn signs which should ring your bells to prevent an actual charge.
(If you see a group of boars,) at least one of the boars will become
more active now, usually a juvenile, and will walk towards you, maybe
a little nervous, sometimes turning round to return to the others. The
move towards you is for a better look, for they have very poor
eyesight. Others may soon join in. It may take just a few seconds
for this to happen.
Now, this is not aggression. They are not ganging up on you, but are
being brave and facing their potential threat. They are like children
now, excited and about to be proud of warning mum that they have
spotted you. Mum may now join in, sniffing you and deciding whether to
walk or run away. If she decides to run, she will belt out a loud
grunt or snort, and turn tail. At this moment, all the younger boar
will also flee at high speed away from you. It's all rush and noise,
and you hear feet stampeding away. That's usually it.
Mum may stop shortly afterwards and take another look at you, maybe
even walk back towards you. Again, this is not aggression. She is
saying to you, "You saw how fast we are so don't bother following."
She will either stay and start feeding again, or if you move towards
her in the hope of a photo, she will grunt again and run.
How does a boar behave if push comes to shove?
Friends of the boar and Wikipedia:
Even in these terrible circumstances for the boar, the boar attack is
very fast and is not a charge made from many meters away. The boar are
close to the aggressor, maybe just a second or two away.
Actual attacks on humans are rare, but can be serious, resulting in
multiple penetrating injuries to the lower part of the body. They
generally occur during the boars' rutting season from
November–January, in agricultural areas bordering forests or on paths
leading through forests. The animal typically attacks by charging and
pointing its tusks towards the intended victim, with most injuries
occurring on the thigh region. Once the initial attack is over, the
boar steps back, takes position and attacks again if the victim is
still moving, only ending once the victim is completely incapacitated.
Also be aware that there might be a different "charge style":
A female bites you. Her head doesn't lower. Instead, look for her
shackles on the shoulders to rise and maybe her tail stand erect. She
will also growl.
How to react
A boar doesn't charge instantly. It gives you warnings (a lot of them actually - see the previous section). I know, the question is more about the point where it's already too late, but it's worth to mention how you can prevent a charge in the first place.
(If a) boar may walk straight at you (...), stand tall and shout at
(it). Move towards (it) confidently but not aggressively, and (it) will
probably move out of your way.
If (it) follows you don't panic but
keep walking away - (it) will soon get fed up. Just be confident, if
(it) is tame she will not hurt you.
Nearly the same thing applies to react to a the described "bite attack". If ever you see these signs, move away confidently, reassuring her with soft words rather than screams or shouts.
You may sometimes hear a growl from scrub where she is hiding with her
piglets. If you ever hear growling in the scrub, don't wait to see her, go back immediately from where you came.
You should take these actions to defend yourself:
How to Survive if Threatened:
If you ever have a faceoff with a hostile pig your best option to defend yourself may be to climb the nearest tree, boulder, car, etc.
You want to get at least 6 feet off of the ground because large pigs can somewhat "walk" up a tree trunk with their front legs.
If a pig charges and you can't escape you can try to sidestep very quickly to avoid the potential swing of its tusks.
Your last resort may be to physically fight back with whatever means possible until the mauling ends.
While fighting back try to remain standing. People who fall or are knocked to the ground can sustain more serious injuries.
Most assaults on humans are over in under one minute.
Taken from http://www.backcountryattitude.com/wild-pigs.html. ab2 found this nice resource:
See backcountryattitude.com/wild-pigs.html for wild pig attack and
what to do. It's too long for me to summarize -- as a hunter, you
would find it easier to summarize it as an Answer than I would.
Further reading
As the victims of boar attack are usually recovered from dense forest
areas, the investigating officers could be misled as to the nature of
infliction of these multiple, fatal penetrating injuries to a possible
homicide. Unlike the injuries inflicted by wild cats, canines and
bulls, the hallmark of boar attack is the infliction of multiple
penetrating injuries to the lower part of the body. This case is
reported for its rarity, for the awareness of the possible injuries in
such unnatural deaths, and for the factors predisposing to a boar
attack.
Lower extremity lacerations of up to 10 cm in length and 4 cm deep
were seen in the 3 cases reviewed.