• 締切済み

javaの日本語プログラムについて

お世話になります。 JAVAのプログラミングについて、ご質問させてください。 今回、プロジェクトで利用を検討しているツールがあって、 そのツールから、javaのクラスを自動生成して、プロジェクト で利用することを検討しています。 ちなみに、作成予定のシステムはWebアプリケーションです。 ただ、ここで問題になっていることが、ツールから吐き出されるソースのjavaのオブジェクトの名称が日本語で記述されているという何ともナンセンスな仕様になっているということです。 実際に、自動生成したクラスを呼び出すプログラムのサンプルイメージは以下の通りです。 import CorticonService.Cargoデシジョンサービス; import CorticonService.CargoデシジョンサービスLocator; import CorticonService.CargoデシジョンサービスSoap; public class ServiceTest { 中略… Cargoデシジョンサービス service = new Cargoデシジョンサービ    スLocator(); CargoデシジョンサービスSoap soap = null; try {    soap = service.getCargoデシジョンサービスSoap();     } catch (ServiceException e1) { // TODO 自動生成された catch ブロック    e1.printStackTrace(); } CorticonResponseType res = null; try {   res = soap.processRequest(param);     } catch (RemoteException e) {       // TODO 自動生成された catch ブロック   e.printStackTrace();     }   } …っといったような記述になります。我ながら、こんなプログラムを書きたくないな~っとは思うのですが、ローカルでの検証では問題なく動きます。ただ、実際に上記のような日本語JAVA?を含むプログラムを多種多様な環境で動作させようとした場合、どのような弊害が発生する可能性が あるのでしょうか? こんな質問をすることは、馬鹿げているかもしれませんが経験の浅さからか自分自身検討がつきません。。。 どなたかお答え願えませんでしょうか?

みんなの回答

  • luckymako
  • ベストアンサー率55% (29/52)
回答No.4

吐かれたソースの文字コードは何ですか? Unicodeなら問題ないでしょう。 他のコードならASCII文字以外は使わないのがいいと思います。

全文を見る
すると、全ての回答が全文表示されます。
  • thamansa
  • ベストアンサー率40% (95/232)
回答No.3

こういう選択肢があると思います。 ・ツールに入力するときから、Javaクラス名を意識して英語またはローマ字で入力する。(CargoDecisionService) ・ツールから出力されるファイルの日本語を変換するツールを作成する。(デシジョンサービス→DecisionService) このツールを使わない場合でも、設計時の日本語をいつかはJavaクラス名にする辞書を作るわけですから、どのタイミングでクラス名にするかですね。

全文を見る
すると、全ての回答が全文表示されます。
  • rinkun
  • ベストアンサー率44% (706/1571)
回答No.2

Javaの場合、クラス名と記述するファイル名を一致させるようにしているので、ソースファイルの文字コードとファイル名の文字コードの関係によってトラブルが発生する可能性はあります。 まあ現在のちゃんと設定された日本語環境のあるOS上なら問題ないかもしれませんけど。

全文を見る
すると、全ての回答が全文表示されます。
  • _ranco_
  • ベストアンサー率58% (126/214)
回答No.1

ふつうに日本語環境のあるマシンとOSの上なら、なにも問題ないはずです。 なお、ソースについては、各プラットホームの上で開発等をするなら、各プラットホームのデフォルトのエンコーディングで書かれている必要があります。でも、テキストファイルのエンコーディング変換は簡単でしょう。

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • javaプログラムについて

    javaのプログラムで入力項目をDBに書き込むというプログラムを作成しているのですが、 コンソール形式だと成功するのですが、テキストボックスなどをおいて、GUI形式でやろうとするとキーイベントの中の変数ににうまく値が参照されません 以下ソース import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants; import java.awt.Container; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.text.SimpleDateFormat; import java.util.Date; class meibo3 extends JFrame implements KeyListener { public static void main(String args[]) { meibo3 frame = new meibo3("タイトル"); frame.setVisible(true); } // private String name; // private String shu; // private int id; // private int su; meibo3(String title) { setTitle(title); setBounds(100, 100, 300, 250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); p.setLayout(null); JLabel lmeibo = new JLabel("【名簿入力】", SwingConstants.CENTER); lmeibo.setBounds(100, 10, 80, 30); JLabel lgakuno = new JLabel("学生番号", SwingConstants.CENTER); lgakuno.setBounds(30, 40, 80, 30); JLabel lname = new JLabel("氏 名", SwingConstants.CENTER); lname.setBounds(200, 40, 80, 30); JLabel lshu = new JLabel("入力を終了しますか?(Y/N)"); lshu.setBounds(30, 120, 200, 30); JTextField gaku = new JTextField(4); gaku.setBounds(30, 70, 80, 30); JTextField namae = new JTextField(20); namae.setBounds(200, 70, 80, 30); JTextField y = new JTextField(20); y.setBounds(200, 120, 20, 30); y.addKeyListener(this); ; p.add(lmeibo); p.add(lgakuno); p.add(lname); p.add(gaku); p.add(namae); p.add(y); p.add(lshu); Container contentPane = getContentPane(); contentPane.add(p, BorderLayout.CENTER); int id = Integer.valueOf(gaku.getText()).intValue(); String name = namae.getText(); int nsu = namae.getText().length(); String yn =y.getText(); //method(id,name,nsu,yn); } public void keyPressed(KeyEvent ke) { // TODO 自動生成されたメソッド・スタブ if (ke.getKeyCode() == ke.VK_ENTER) { //private void method(int id, String name, int nsu, String yn){ Date d = new Date(); SimpleDateFormat dfd = new SimpleDateFormat("yyyy-MM-dd"); Connection con = null; String day = dfd.format(d); // System.out.print(day); PreparedStatement ps = null; try { // ドライバクラスをロード Class.forName("com.mysql.jdbc.Driver"); // データベースへ接続 con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/hellodb", "root", "root"); Statement stmt = (Statement) con.createStatement(); // name,bloodType,ageのデータを検索するSQL文を作成 String sql = "INSERT INTO hellodb.meibo VALUES(" + id + ",'" + name + "','" + day + "');"; System.out.println(sql); if (id > 4 && nsu > 20) { // JOptionPane.showMessageDialog(this, "学生番号が4桁以上、氏名が20文字以上になっています。", "Error", // JOptionPane.ERROR_MESSAGE); } else { if (id < 5) { // JOptionPane.showMessageDialog(this, // "学生番号が4桁以上になっています", "Error", // JOptionPane.ERROR_MESSAGE); } else { if (nsu > 20) { // JOptionPane.showMessageDialog(this, // "氏名が20文字以上になっています。", "Error", // JOptionPane.ERROR_MESSAGE); } else { if (yn.equals("y") || yn.equals("y") || yn.equals("Y") || yn.equals("Y")) { // ps = con.prepareStatement(sql); stmt.execute(sql); // JOptionPane.showMessageDialog(this, // "成功しました", "Info", // JOptionPane.INFORMATION_MESSAGE); } else if (yn.equals("n") || yn.equals("n") || yn.equals("N") || yn.equals("N")) { } } } } } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { try { // close処理 if (ps != null) { ps.close(); } // close処理 if (con != null) { con.close(); } } catch (SQLException e) { e.printStackTrace(); } } } } public void keyReleased(KeyEvent arg0) { // TODO 自動生成されたメソッド・スタブ } public void keyTyped(KeyEvent arg0) { // TOD

  • javaについて

    こういうプログラムを組んだんですが、うまく実行できません。 どんな改善をしたらよいでしょうか? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class Sample { public static void main(String[] args) { String htmlSrc = getHTMLSrc("http://search.yahoo.co.jp/search?p=java", "UTF-8"); htmlSrc = htmlSrc.replaceAll("<.+?>| ", ""); htmlSrc = htmlSrc.replaceAll(".*件-", ""); htmlSrc = htmlSrc.replaceAll("秒.*", "秒"); System.out.println(htmlSrc); } private static String getHTMLSrc(String strURL, String charSet) { StringBuffer sb = new StringBuffer(); HttpURLConnection conn = null; BufferedReader br = null; try { URL url = new URL(strURL); conn = (HttpURLConnection)url.openConnection(); InputStreamReader isr = new InputStreamReader(conn.getInputStream(), charSet); br = new BufferedReader(isr); String tmp = ""; while ((tmp = br.readLine()) != null) { sb.append(tmp); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null) { br.close(); } if (conn != null) { conn.disconnect(); } } catch (IOException e) { e.printStackTrace(); } } return sb.toString(); } } 以下のエラーが表示されるんですが、どうしたらよいでしょうか?? 環境が悪いのでしょうか?? java.net.ConnectException: Operation timed out

    • ベストアンサー
    • Java
  • Javaの問題について...

    import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.UnknownHostException; import javax.swing.JTextArea; public class html_getter { public static void main(String[] args){ Object o1 = null; try { o1 = new Getter5(new URL("http://www.google.com/")); } catch (MalformedURLException e) { e.printStackTrace(); } ((Getter5)o1).Show(); } } class Getter5{ private String charset = "Shift_JIS"; private JTextArea htmlArea; public Getter5(URL url){ htmlArea = new JTextArea(); try { URLConnection uc = url.openConnection(); BufferedInputStream bis = new BufferedInputStream(uc.getInputStream()); BufferedReader br = new BufferedReader(new InputStreamReader(bis, charset)); htmlArea.setText("");//初期化 String line; while ((line = br.readLine()) != null) { htmlArea.append(line + "\n"); } } catch (MalformedURLException ex) { htmlArea.setText("URLが不正です。"); ex.printStackTrace(); } catch (UnknownHostException ex) { htmlArea.setText("サイトが見つかりません。"); } catch (IOException ex) { ex.printStackTrace(); } } public void Show(){ System.out.println(htmlArea.getText()); } } このプログラムはURLの指定先からHTMLを取ってきて表示するプログラムなのですが、 これに「indexOfとString s1を使ってURLの指定先のHTMLから自分の入力した文字列があるかどうかを判断するプログラム」を作りたいのですがどうすれば作れるでしょうか?

  • JavaからMDB接続について

    下記PGについて ------------------------------------ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class ClassDatabase { public static Connection connection; public static Statement statement; public static ResultSet resultSet; public void main(String DBNM) { try { // Load the UCanAccess JDBC driver Class.forName("net.ucanaccess.jdbc.UcanaccessDriver"); // Define the database URL String url = "jdbc:ucanaccess://" + DBNM + ";"; // Establish the connection DB_CONNECT(url); } catch (ClassNotFoundException e) { e.printStackTrace(); } } public static void DB_CONNECT(String url) { try { connection = DriverManager.getConnection(url); } catch (SQLException e) { e.printStackTrace(); } finally { // Close the connection when you're done if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } ------------------------------------ connection = DriverManager.getConnection(url);の所ですが応答が帰って来ないほど遅いのですがどうにかなりますでしょうか? MDBと接続はできています。(整合性チェック等を行っているようです、させない方法等ありますでしょうか?)

    • ベストアンサー
    • Java
  • Javaプログラムの繋げ方について。

    Javaプログラムの繋げ方について。 今まで(1)のようなプログラムを書いていました。 作りたいものに向けて色々検索するとやりたいものに近い(2)のようなサンプルプログラムを見つけました。 しかし、Java初心者なもので混ぜ方(?)がわかりません。 現在の私の知識からいうと今までのはアプレットでフレーム使うのはアプリケーションなのかな?別物なのかな?そんな感じです。 もし、混ぜることができるなら何かアドバイスをお願いします。 (1)package test; import java.applet.* ; import java.awt.Label ; import java.awt.Font ; import static java.awt.Font.BOLD ; import java.util.*; import java.awt.Graphics; import java.awt.Image; import java.awt.*; public class test extends Applet{ public void paint(Graphics g){ g.setColor(Color.red); g.fillOval(320, 200, 100, 100); } public void init () { ~~~~~~~~~~~~~~~~ } public void start () { ------------ }}} (2)import java.awt.*; import java.awt.event.*; public class MouseEvent7 extends Frame { int posX = 50; int posY = 50; public static void main(String [] args){ new MouseEvent7(); } //コンストラクタ MouseEvent7(){ this.addWindowListener(new WinAdapter()); //ウィンドウリスナーの登録 this.setSize(200,200); this.setVisible(true); //MouseMotionListenerの登録 addMouseMotionListener( new MouseMotionAdapter(){ public void mouseMoved(MouseEvent e){ posX = e.getX(); posY = e.getY(); repaint(); //paintメソッドを実行 } } ); } public void paint(Graphics g){ g.drawOval(posX,posY,50,50); } } (1)の内容に本当に(2)のプログラムで出来るマウスの動きに合わせて円も動く+クリックしたらそこで止まるだけいいのですが。 出来たら止まった点の座標も取りたいですが、そこまではいってません;;

  • itextの日本語のエラー(バージョンアップ)

    itext-1.3.jarからitextpdf-5.4.0.jarにjavaのプログラムを 移行していますが、日本語が表示出来なくエラーになります。 解決策をお教えください。 インタネットで調べて、 iText(PDFライブラリ)の新しいバージョンで日本語がトラブル件で iTextAsian.jarを解凍、comフォルダの下にあるlowagieフォルダを itextpdfにリネーム、iTextAsian.jarの再圧縮 してみましたが解決出来ません  下記にソースコードが有ります import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; //日本語 //iTextAsian.jar //iTextAsianCmaps.jar //itextpdf-5.4.0.jar エラーになる //import com.itextpdf.text.Document; //import com.itextpdf.text.DocumentException; //import com.itextpdf.text.Font; //import com.itextpdf.text.PageSize; //import com.itextpdf.text.Paragraph; //import com.itextpdf.text.pdf.BaseFont; //import com.itextpdf.text.pdf.PdfWriter; //itext-1.3.jar OK import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfWriter; import java.io.ByteArrayOutputStream; public class test12 extends HttpServlet { private static final long serialVersionUID = 1L; public test() { super(); } public static void samplepdf(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); Document document = new Document(PageSize.A4); PdfWriter pdfwriter = null; try { pdfwriter = PdfWriter.getInstance(document, buffer); } catch (DocumentException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } document.open(); BaseFont bf = null; try { bf = BaseFont.createFont("HeiseiKakuGo-W5","UniJIS-UCS2-H",BaseFont.EMBEDDED); Font font = new Font(bf, 12); document.add(new Paragraph("ABCD漢字",font)); } catch (DocumentException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } document.close(); response.setContentType("application/pdf"); response.setContentLength(buffer.size()); ServletOutputStream output = response.getOutputStream(); output.write(buffer.toByteArray()); output.close(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { samplepdf(request,response); } }

  • javaの画像の表示のプログラムとmouselistenerのプログラ

    javaの画像の表示のプログラムとmouselistenerのプログラム(それぞれ↓にあります)をひとつに合わせたいのですがどうすればいいでしょうか? import java.awt.event.*; import javax.swing.*; class MyPanel extends JPanel implements MouseListener{ public MyPanel() { addMouseListener(this); } public void mouseClicked(MouseEvent e) { int x=e.getX(); int y=e.getY(); System.out.println("マウスがクリックされました (" + e.getX() + ", " + e.getY() + ")"); if((x<100&&x>40)&&(y<100&&y>40)){ System.out.println("範囲内"); }else{ System.out.println("aaa"); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } } public class MouseEventExample extends JFrame { public static void main(String[] args) { new MouseEventExample(); } MouseEventExample() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(new MyPanel()); setSize(300, 200); setVisible(true); } } ======↑のプログラムと↓のプログラムを合わせたいのです package novel; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; import javax.swing.*; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import java.io.IOException; public class Java2dTest extends JFrame{ public static void main(String[] args){ Java2dTest test = new Java2dTest(); test.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){System.exit(0);} }); test.setBounds( 0, 0, 200, 200); test.setVisible(true); } public void paint(Graphics g){ Graphics2D g2 = (Graphics2D)g; BufferedImage readImage = null; try { readImage = ImageIO.read(new File("sample.png")); } catch (Exception e) { e.printStackTrace(); readImage = null; } if (readImage != null){ g2.drawImage(readImage, 0, 0, this); } } }

  • JavaのRMIで!!

    クライアントから呼び出してサーバーでhogehogeを表示させるようにこんなプログラムを書きました。 command.javaが以下の内容 import java.rmi.*; interface command extends Remote{ void comcom() throws RemoteException; } commandclient.javaが以下の内容 import java.rmi.*; public class commandclient { public static void main(String args[]) { command obj = null; try { System.setSecurityManager(new RMISecurityManager()); obj = (command)Naming.lookup("rmi://localhost/MyObject"); obj.comcom(); } catch(Exception e) { e.printStackTrace(); } } } commandserver.javaが以下の内容 import java.rmi.*; import java.rmi.server.*; public class commandserver extends UnicastRemoteObject implements command { public static void main(String args[]) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { commandserver obj = new commandserver(); Naming.rebind("MyObject", obj); } catch (Exception e) { e.printStackTrace(); } } public commandserver() throws RemoteException { } public void comcom() throws RemoteException { System.out.println("hogehoge"); } } こんなプログラムを書いてコンパイルして実行したらhogehogeが表示されるかな?と思ったら実効するとなんか意味不明なエラーがでます。これはなぜでしょうか?

  • java.lang.OutOfMemoryErrorというエラーがでる。

    javaを勉強しています。タイトルのように java.lang.OutOfMemoryErrorというエラーが出てしまいます。少し調べてみたらどうやらメモリーの使いすぎ(?)のようなのですが、プログラムの方に問題があるのでしょうか?それとも使えるメモリーを増やすといった解決策を取ったほうがいいのでしょうか? よろしくお願いします。プログラムはまず画像が表示されて、左クリックすると次の画像へ変わる、といった処理をするアプレットです。 package jibundesukosidutu; import java.applet.Applet; import java.awt.Graphics; import java.awt.MediaTracker; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class Main extends Applet implements MouseListener{ File[] imagelist; File image = new File("image"); BufferedImage drawImage; static int i = 0; MediaTracker mt = new MediaTracker(this); public void init(){ imagelist = image.listFiles();//ディレクトリの画像ファイルたちを配列に入れていく。 addMouseListener(this); try { drawImage = ImageIO.read(imagelist[i]);//drawImageメソッドで画像ファイルとして引数を取れるように、型変換しておく。 } catch (IOException e) { e.printStackTrace(); } } public void paint(Graphics g){//drawImageファイルを表示するだけ int w, h; w = getSize().width; h = getSize().height; mt.addImage(drawImage,0); try { mt.waitForID(0); } catch (InterruptedException e) { e.printStackTrace(); } g.drawImage(drawImage,0,0,w,h,this);//imagelist[0]を表示したい。 } public void mouseClicked(MouseEvent e) { int btn = e.getButton(); if(btn == MouseEvent.BUTTON1){//左クリック=進め System.out.println("左クリック"); i++; //searchFile(true); try { drawImage = ImageIO.read(imagelist[i]); } catch (IOException e1) { e1.printStackTrace(); } repaint(); }else if(btn == MouseEvent.BUTTON2){ System.out.println("右クリック"); //searchFile(false); } } public void searchFile(boolean next){ //next→次の画像、false→前の画像 } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }

    • ベストアンサー
    • Java
  • Javaが途中で止まってしまいます

    Javaで音声ファイルを変換するスクリプトなのですが、音声ファイル自体は認識して「ファイルコピー終了」と出るのですが、実際にはコピーされておらず、そこで終わってしまい変換工程まで辿り着かない状態です。 ============================== import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class OnseiFileConvert { /** * @param args */ public static void main(String[] args) { OnseiFileConvert exe = new OnseiFileConvert(); exe.execute(); } /** m = 0x80; for( i=0; i<fsize; i++, m++ ) { if( m == 0xFF ) { m = 0x80; } fread( &t, 1, 1, fp ); t = t^m; fwrite( &t, 1, 1, fp_out ); } */ public void execute(){ String voice_dir_in = "C:\\java\\onsei"; String voice_dir_out = "C:\\output\\onsei"; try { convVoice(voice_dir_in,voice_dir_out); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * 音声変換処理 * @throws IOException * @throws InterruptedException */ private void convVoice(String voice_dir_in,String voice_dir_out) throws IOException, InterruptedException{ System.out.println("ディレクトリーコピー開始"); System.out.println("xcopy /T /E \"" + voice_dir_in + "\" \"" + voice_dir_out +"\""); Process proc = Runtime.getRuntime().exec( "xcopy /T \"" + voice_dir_in + "\" \"" + voice_dir_out +"\""); proc.waitFor(); proc.destroy(); System.out.println("ディレクトリーコピー終了"); System.out.println("ファイルコピー開始"); convData(voice_dir_in, voice_dir_out); System.out.println("ファイルコピー終了"); } /** * @param voice_dir_in * @param voice_dir_out * @throws IOException * @throws InterruptedException */ private void convData(String voice_dir_in, String voice_dir_out) throws IOException, InterruptedException { System.out.println(voice_dir_in + "/" + voice_dir_out); File in_file = new File(voice_dir_in); File[] in_files_list = in_file.listFiles(); for(int i = 0; i < in_files_list.length ; i++ ){ File chFile = in_files_list[i]; if(chFile.isDirectory()){ convData(voice_dir_in + "\\" + chFile.getName() ,voice_dir_out + "\\" + chFile.getName() ); } else { String file_name = chFile.getName(); System.out.println(file_name); if(".".equals(file_name.substring(0, 1))){ file_name = file_name.substring(1, file_name.length()-4); File ofile = new File(voice_dir_out + "\\" + file_name); if( ofile.length() == 0 ){ convFile(voice_dir_in + "\\" + chFile.getName(),voice_dir_out + "\\" + file_name); } } } } } /** * ファイル単位に変換を実施する処理 */ private void convFile(String input_file_name,String out_file_name) { //convert FileInputStream fip = null; FileOutputStream fop = null; try { System.out.println("変換開始"); fip = new FileInputStream(input_file_name); fop = new FileOutputStream(out_file_name); long fsize = (new File(input_file_name)).length(); int m = 0x80; for( int i=0; i< fsize; i++, m++ ) { if( m == 0xFF ) { m = 0x80; } int t = fip.read(); t = t^m; fop.write(t); } System.out.println("変換完了" + fsize + "Byte"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ try { if(fip != null){ fip.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { if(fop != null){ fop.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } ============================== 長時間悩んで書き直したりしたのですが、やはり結果が変わらずお手上げ状態です。 どうぞご助力お願いします。

    • ベストアンサー
    • Java