Bläddra i källkod

dev 1st completed

shjung 2 år sedan
förälder
incheckning
73844b50f3

+ 10 - 15
src/main/java/com/its/dsrc/DsrcCommServerApplication.java

@@ -39,33 +39,28 @@ import java.awt.event.WindowEvent;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.lang.reflect.Field;
 import java.net.URL;
+import java.nio.charset.Charset;
 
 @Slf4j
 @EnableAsync
 @Configuration
 @SpringBootApplication
 @ComponentScan(basePackages = {"com.its.dsrc.config", "com.its.dsrc.dao.mapper", "com.its"})
-//java -jar app.jar --spring.config.location=classpath:/another-location.properties
-//java -jar app.jar --spring.config.location=config/*/
-//java -jar app.jar --property="value"
-//java -Dproperty.name="value" -jar app.jar
-//export name=value
-//java -jar app.jar
-//JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=prod"
-
-//@PropertySource("classpath:foo.properties")
-//@PropertySource("classpath:bar.properties")
-//@PropertySources({
-//        @PropertySource("classpath:foo.properties"),
-//        @PropertySource("classpath:bar.properties")
-//})
-//public class DsrcCommServerApplication implements CommandLineRunner, ApplicationListener<ContextClosedEvent>, InitializingBean, DisposableBean {
 public class DsrcCommServerApplication implements CommandLineRunner, ApplicationListener<ContextClosedEvent>, InitializingBean, DisposableBean {
 
     private static String applicationName = "dsrc-comm-server";
 
     public static void main(String[] args) {
+        System.setProperty("file.encoding","UTF-8");
+        try {
+            Field charset = Charset.class.getDeclaredField("defaultCharset");
+            charset.setAccessible(true);
+            charset.set(null,null);
+        } catch(Exception e){
+        }
+
         File file1 = new File("./conf/" + applicationName + ".pid");
         if (file1.exists()) {
             System.out.println(System.getProperty("Program Already Running....."));

+ 6 - 26
src/main/java/com/its/dsrc/ui/JTextAreaOutputStream.java

@@ -16,33 +16,13 @@ public class JTextAreaOutputStream extends OutputStream {
         this.logArea = logArea;
     }
 
-//    public synchronized void logWrite(String text) {
-//        Runnable  runnable = new Runnable() {
-//            public void run() {
-//                logArea.append(text);
-//                if (logArea.getDocument().getLength() >
-//                        50000) {
-//                    try {
-//                        logArea.getDocument().remove(0, 5000);
-//                    } catch (BadLocationException e) {
-//                        //log.error("Can't clean log", e);
-//                    }
-//                }
-//                logArea.setCaretPosition(logArea.getDocument().getLength());
-//            }
-//        };
-//        SwingUtilities.invokeLater(runnable);
-//    }
-
     @Override
     public void write(byte[] buffer, int offset, int length) throws IOException
     {
         if (isLoggingPause) {
             return;
         }
-
         final String text = new String(buffer, offset, length);
-        //logWrite(text);
         SwingUtilities.invokeLater(new Runnable ()
         {
             @Override
@@ -61,9 +41,10 @@ public class JTextAreaOutputStream extends OutputStream {
 
     @Override
     public void write(int b) throws IOException {
-//        if (b == '\r')
-//            return;
-
+        if (isLoggingPause) {
+            sb.setLength(0);
+            return;
+        }
         if (b == '\n') {
             final String text = sb.toString() + "\n";
             SwingUtilities.invokeLater(new Runnable ()
@@ -82,9 +63,8 @@ public class JTextAreaOutputStream extends OutputStream {
                 }
             });
         } else {
-            sb.append((char) b);
+            sb.append(String.valueOf((char)b));
+            //sb.append((char) b);
         }
-
-        //write (new byte [] {(byte)b}, 0, 1);
     }
 }