Humbled and crippled by foreign competition, Japan's once all-conquering textile industry is in headlong retreat. Huge losses and mounting stockpiles of unsold goods have forced hundreds of firms across the country into factory closures, desperate and frequently unsuccesful flings in alternate ventures and finally bankruptcy.

The future is bleak. Southeast Asian textile makers - many equipped with modern Japanese-made plants - are capturing traditional export markets and are shipping increasing quantities into Japan itself.

Nowhere is the despondency worse than in the commercial capital of Osaka which boomed with the textile industry's heyday and is suffering in its decline. "It's still a vital industry for us, and the long recession has had a severe impact on the city," said Mayor Yasushi oshima. Once the heart of an industry which powered Japan's immediate post-war growth and led the world in cloth and garment exports, Osaka is haunted these days by deficit-ridden textile firms, extended banks and thousands of workers anxious about their jobs and future.

In 11 months last year, 817 textile companies declared bankruptcy with total debts of more than $450 million.

According to industry sources, all the major companies are losing money and some are staying afloat only by selling abandoned factrories for real estate development to pay big bank debts. Shrunken expense accounts have dulled the glitter of Osaka's Shinchi entertainment district with bar and restaurant takings down.

Osaka businessmen who used to greet one another with "Nambo mokattemaska?" - Now much money are you making? - Now say "Akana" - miserable. A golf driving range and failed bowling center on an empty factory site in the downtown area are symbolic of the textile industry's failure in diversification adventures. Faced with the need to remodel their troubled corporations, Japanese managers have provied no more adaptable than their European counterparts. Because they lacked technology and experience for entry into complex new industries, the textile makers invested in recreation - hotels and bowling alleys. Many of those ventures now are closed.

With its heavy reliance on manual labor and imported raw materials, the textile industry is the first victim of Japan's transition to a high-wage, industrially advanced nation.

Veteran executive M. Tezuka is trying to reconstruct a spinning company which went bankrupt two years ago owing close to $200 million: "A Japanese girl worker gets $10 a day for 270 days a year. A Korean girl gets $2.50 and works 365 days. We just can't compete with that," he explained. While the company's Japanese factory is narrowly breaking even, a joint venture in South Korea is reaping handsome profits.

Working form the dead former owner's office, Tezuka, like many other harassed mill managers, would like to close out the unprofitable operation. The unions have prevented it.

With approximately 2.7 million workers scattered throughout Japan in mills, Mom and Pop weaving and dying operations, and thousands of clothing manufacturers, the textile industry is still the nation's leading employer.

Jobs are being lost, and fast. Between 1973 and 1975, at least 300,000 people dropped from the industry's payroll as factories went out of business. Still, disruption has been minimized by sharing the hardships. Under the tradition of lifetime employment, major companies paid many workers to accept early retirement and found jobs for others in the expanding auto and electronics industries. Thousands of young girl workers who left to get married healped the drawdown.

In the surviving plants, workers have accepted wage freezes and partial layoffs to keep their jobs. For union representative Hitoshi Taguchi, 41, the end of overtime in his 600-worker company costs him $90 a month and his wife has started working to make up the difference. "The company is now talking about layoffs," he said. "Many young families who wanted to buy their own houses have had to abandon their plans."

So far, wholesale sackings have been avoided, yet the shrinkage has inflicted more subtle pains by thwarting dreams and gnawing away at living standards throughout the industry.